Query specific sheets of a google spreadsheet Query specific sheets of a google spreadsheet json json

Query specific sheets of a google spreadsheet


Ok, I have a solution for anyone who is interested, although it is not as sensible as I would have hoped

Thanks to the below blogpost

http://damolab.blogspot.co.uk/2011/03/od6-and-finding-other-worksheet-ids.html

It seems that the id for specific sheets is the /od6/ part of the URL and od6 is the default name given to the first, default, sheet

"https://spreadsheets.google.com/feeds/list/0Ak0qDiMLT3XddHlNempadUs1djdkQ0tFLWF6ci1rUUE/od6/public/values?alt=json-in-script&callback=?"

In the above blog post there is an example of how to find out the IDs of specific sheets if you need. There doesn't seem to be a clean logic to it but changing it will spit out the data from specific sheets so it works.


I realize this is an old post, but I have been fighting this for a while. I made my own library to take care of this and I hope this saves someone many hours of research and playing with the google api. The general format is almost verbatim from the google documentation and I removed error checking to stay concise. What I could not find in the google documentation was how to query a tab that isn't the first one. I think this is what we are looking for here.

Based on what you already have, this should answer it.

table_name_here/gviz/tq?sheet=tab_name_here

As an example for all those that come after you:

https://docs.google.com/spreadsheets/d/17mbdvl1jVpqj42E3BSX34q9XUA2PbYubYKpVeypbHLA/gviz/tq?sheet=Sheet1This could be used as the table_string in the code below.

'SELECT *'This could be used as the query_string in the code below.

Within context:

function gimmeATable(){ var query = new google.visualization.Query('table_string'); query.setQuery('query_string'); query.send(handleQueryResponse); }

function handleQueryResponse(response){ var data = response.getDataTable; drawTable(data); }

function drawTable(data){ var table = new google.visualization.Table(document.getElementById('div1')); table.draw(data, {showRowNumber: true}); }

And don't forget to include the google api as well as package type. For this you only need a table.

<script type="text/javascript" src="https://www.google.com/jsapi"></script> google.load("visualization", '1', {packages:['table']});