Reputation: 63
I used google-apis SDK for my development. I can able to get values from sheet by using sheets.spreadsheets.values.get
method. But it returns entire values from that sheet. I need to filter something like querying.
Here what I actually trying,
Assume the above data as a spreadsheet, Here sheets.spreadsheets.values.get
this returns whole values from that sheet. But I try to do fetch first row by [email protected]
Upvotes: 2
Views: 2788
Reputation: 26836
The method spreadsheets.values.get allows (and requires) you to specify a range
A sample value for range
- for getting row 5 of Sheet1 would be Sheet1!A5:Z5
UPDATE
If you do not know which row you want to retrieve, but want to incorporate a query request, such as in the Google Sheets UI:
It is not possible with Google Sheets API.
But there is a workaround:
Use a Google Visualization API query.
Workflow:
https://docs.google.com/a/google.com/spreadsheets/d/XXXXXX
/gviz/tq?tq=
Sample:
If your query is select A
,
https://docs.google.com/spreadsheets/d/XXXXX/gviz/tq?tq=select%20A
google.visualization.Query.setResponse({"version":"0.6","reqId":"0","status":"ok","sig":"1023816999","table":{"cols":[{"id":"A","label":"","type":"number","pattern":"General"}],"rows":[{"c":[{"v":1.0,"f":"1"}]},{"c":[{"v":4.0,"f":"4"}]}],"parsedNumHeaders":0}});
You can access the nested JSON structure as desired and of course you can formulate your query as desired.
Upvotes: 2