I know how to query data from google spreadsheet with the general share link, but I want to pull data from specific tabs in that shared workbook. How do I do this?
It is not clear from your question how you are querying a spreadsheet (there are several ways to do it).
If you are using spreadsheet data source url (e.g: https://docs.google.com/spreadsheets/d/{ss_key}/gviz/tq?tq=...), then you can add gid or sheet url parameters to specify which sheet in the spreadsheet to query by its id or name:
https://docs.google.com/spreadsheets/d/{ss_key}/gviz/tq?gid=0&tq=...
https://docs.google.com/spreadsheets/d/{ss_key}/gviz/tq?sheet=Sheet1&tq=...
You can get the gid number of a sheet from the spreadsheet's url when it is open in your browser. More info here: https://developers.google.com/chart/interactive/docs/spreadsheets#Google_Spreadsheets_as_a_Data_Source
Note: data source url examples above are for new google sheets. If you are still using old sheets, the url format will be different: http://spreadsheets.google.com/a/google.com/tq?key=ABCDE&tq=.... The documentation link above still uses old sheets url format.
If you are querying your spreadsheet via QUERY() formula in another sheet, then just specify the name of the sheet you want to query in the data attribute of the function:
=QUERY('Example Data'!$A$2:$H$7, "select A where (B<>'Eng' and G=true) or (D > "&A2&")")
Related
Is there a way that I am able to convert a list of Google Form Responses to Google Sheets as a viewer? I have permission to view previous responses, but I am not the owner of the forms.
if you have View access to the spreadsheet you can create a new spreadsheet:
sheets.new
and enter this into A1 cell:
=IMPORTRANGE("URL"; "A:Z")
where URL is the address of the spreadsheet you have View rights and A:Z is the range you want to import. you can even specify the sheet name like: "Sheet1!A:Z" or "Form Responses1!A:Z"
What I knew
is how to link data by
="SheetName!A2:B2" (same file, Differet Sheets)
or
=importrange("Url","sheetName!A2)(Different file)
all these require manual edditing
My Question:
If i have a list of these sheet name, or even it's Url,
How can i get dates from other sheets by using these SheetName or Url?
BTW:
i am trying to build a Table Menu for my Inovice system automatically
i had a file with 100+ sheet, every sheet has the same form, and i had looked up how to generate Sheetname list with url, but when i try to link (Using SheetNAme or Url as clue) to get the total sell amount/ client name / time, i counld't.
SAMPLE
https://docs.google.com/spreadsheets/d/1R67knSxkHD8v6ICIYJtb24pMwV_76HoKLDb-S79lzP4/edit#gid=0
thanks for reading and helping, my english expressing may not be precise ,sorry for that.
In G8, try
=indirect(C8&"!C6")
be sure that the layout of each tab is similar (not the case in your spreadsheet) to expand the formula
I am trying to query data from one of my google spreadsheets, and I have read the docs here.
My spreadsheet has two tabs/sheets. I can query data from the first sheet, but I can't figure out how to query data from the second sheet.
My query url looks like this:
https://docs.google.com/spreadsheets/d/[SpreadSheetId]/gviz/tq?tq=[query]
If I open the sheet in a browser I can see the sheet Id in the browser url:
https://docs.google.com/spreadsheets/d/[SpreadSheetId]/edit#gid=[SheetId]
Is there any way to specify this sheetId in the query url? I have tried adding various versions of /#gid=[sheetId] to my query url but it returns the full html of the page, not the json I expect.
The answer is:
https://docs.google.com/spreadsheets/d/[spreadSheetId]/gviz/tq?gid=[sheetId]&tq=[query]
Credits to tehhowch for pointing me in the right direction!
So I have shared a google workbook and I have created a key and so I can retrieve the structure of the workbook with the following link
Google Sheets - Copy of Guardian University Guide 2018
and in the results I can see the sheets in an array, so first element in an array has sheetId of 1544561606 so I presume somehow I can form a second url with this sheetId as well as original spreadsheet id and get the contents of the this sheet but the documentation is sparse IMHO. THen I can do the same for all the other sheets. I just can't find the correct url format. Please help.
This is version 4.0 of Google Sheets API.
From your endpoint, the sheet name of the sheet ID 1544561606 is "Institutional". You can retrieve the sheet data using this sheet name. The endpoint is as follows.
https://sheets.googleapis.com/v4/spreadsheets/1nDSd38lIQj_aTWDRPJ-aPybR0NwFdQ8GLSDJM0-QaR4/values/Institutional?key=AIzaSyBUHA34c7FmNLut1V7Pe3lIJTk3pX39J6E
Reference :
spreadsheets.values.get
If I misunderstand your question, I'm sorry.
I'm trying to build a webapp based on Google Sheets. I'm a little bit confused with the API. I have a spreadsheet which is shared with me by Drive and contains 2 sheets. I can get the first sheet with
GET /v4/spreadsheets/{spreadsheetId}
Returns the spreadsheet at the given ID.
endpoint. But I couldn't figure out how to get the second sheet. Is there a way I can get spesific sheet from a spreadsheet?
The problem in here is when you are using ranges parameter you have to specify the sheet title with A1 notation syntax as described in this document: https://developers.google.com/sheets/guides/concepts#sheet_id
I was using the ranges parameter and using the A1 notation correctly but I wasn't specifying the sheet title. In that scenario the default sheet is the first one. If you want the get another sheet other than the first one you have to specify the title, like this:
https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}?ranges=sheetTitle!A3:F20