I am trying to use RESTful API to gather the data from a Google spreadsheet spreadsheet.
I read the document at https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/get but I cannot a way that allows me to specify a specific GID (tabs) of the spreadsheet.
After call the API, I was able to get a value from the first tab of the spreadsheet, but I want to change it to the second page (another GID)
Any help would be appreciated. Thanks.
Edit: Added example:
I have a sample spreadsheet here: https://docs.google.com/spreadsheets/d/1da3e6R08S8OoibbOgshyAQy7m9VRGPOrSGzVIvMSXf4/edit#gid=0
When I want to get the value on A1, I can call the RESTful API:
https://content-sheets.googleapis.com/v4/spreadsheets/1da3e6R08S8OoibbOgshyAQy7m9VRGPOrSGzVIvMSXf4/values/A1?key=API_KEY
And I will get:
{
"range": "Sheet1!A1",
"majorDimension": "ROWS",
"values": [
[
"This is on the first tab!"
]
]
}
But as you see in my spreadsheet, I have to tabs (sheet2), how can I get that value of "This is on the second tab!
"?
Get data from other sheets in your spreadsheetType = followed by the sheet name, an exclamation point, and the cell being copied. For example, =Sheet1! A1 or ='Sheet number two'! B4 .
Sheet ID is an identifier of a Sheet in a Google Spreadsheet file. To obtain it, open the file for the desired Sheet, and locate it at the end of the URL after 'gid=' : https://docs.google.com/spreadsheets/d/1EwXZweUNKKGSC6k6_6IkukyRFeNzi7qEIIjOAC9_vGA/edit#gid=ThisIsSheetID .
Google Grid ID (gid) is the sheet ID (tab) used to specify the sheet from which data is being read. The sheetID of the open sheet is the value of the gid parameter at the end of the spreadsheet URL. The gid parameter will be a numerical value.
https://docs.google.com/spreadsheets/d/aBC-123_xYz/edit#gid= sheetId. Cell. An individual field of text or data within a sheet. Cells are arranged in rows and columns, and can be grouped as a range of cells.
To specify a specific GID (tabs) of the spreadsheet. Enter your 'sheet_name' with single quotes. Don't miss to add double quotes for range. Hope it helps
var query = {
auth: authClient,
spreadsheetId: 'spreadsheetID',
range: "'sheet1'!A1:D3",
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With