How to use Google Sheets as a database
2019-08-22 20:26
TOC
本篇中文版:如何用Google Excel當作資料庫
Resources used in this article
The previous article, Fully customizable Google Forms, is about how to use Google Forms as a web form and how to send data to Google Sheets.
In this article, I will write how to use Google Sheets as a database, and I will create a simple member list page to demonstrate.
These tools are used in this article:
- database: Google Sheets
- data sample: uinames.com
- css framework: Skeleton
- source code: Github
Create a Google Sheet
On the google drive, press New, select Google Sheets and you will be taken to a new google sheet.
The data here comes from unnames.com, I chose four fields:
- name
- thumbnail
- birthday
The following are fake members information compiled:

sample memeber data
Publish Google Sheet to the web
This is the easiest and most important step, only the published google sheet will let us AJAX.
First, click on File in the top left corner, and you’ll see the Publish to the web option:

File -> Publish to the web
After clicking Publish to the web, a modal will appear asking for the scope of the release.

select the scope of the release
Because this sheet has only one sheet, so I select Entire Document.
Then click Publish and you will see the modal of successful publishing.

publish success
Create a member list page
The next step is create a page to display the data we catch from the google sheet.
Finally I create a page like this:

demo1 not render data yet
We have page and the data, all we have to do is AJAX google sheet and render the data on the page.
AJAX Google Sheet data
In fact, when we publish the google sheet, it’s easy to AJAX the data. All we need is the request URL.
The structure of the request google sheet url is like this:
|
|
There are two elements that should be replaced here: excel_id, sheet.
The sheet is … yeah, the sheet like excel sheet. We can only GET one at a time.
The excel_id is depending on the url, the google sheet url looks like this:
|
|
So, the URL for my demo google sheet like this is:
|
|
The excel_id is: 1IrmKHvX6tQ8zgzPC3ggD3UPu1-hQrE29nfHRs40wUJQ**
After we put the excel id, sheet into the URL, we can get this:
|
|
Finaly, we use the url to AJAX. I am using jQuery to handle GET method:
The result of console.log:

original data
The next step is to organize the data and use the for loop to render the data:
I use console.table to convert an array to a table:

result of data
Finally, the data is rendered by using for loop into the page. The result is as follows:

final page
I don’t know why, it looks like a dating web sites. XD~
Here is the source code used in this article. Welcome to use:
https://github.com/letswritetw/letswrite-google-excel-db-en
If you find this article helpful, please click on the helpful button made by myself. If you are willing to share on the social, that’s even better.