Google Spreadsheet - select worksheet with JSONP

回眸只為那壹抹淺笑 提交于 2019-12-11 18:13:03

问题


First endpoint

I am reading Google query language specification. This endpoint allows me to query data but I have not figured out how to select page, how can I select page? I tried:

$.ajax({
  dataType: 'jsonp',
  url: 'http://spreadsheets.google.com/a/google.com/tq?key=ABCDE&tq=select%mypage!A'
})

Note the mypage!. But this does not work.

Also, when trying without mypage!, I receive an answer like this:

// Data table response
google.visualization.Query.setResponse({"version":"0.6...

Where should I read about this response? do I need to load some Google Library? why, if I just want the data? is there a better approach to get just data?

Second endpoint

I also read this example. This allows to select worksheet with a code od6, od7 and so on, why it starts in od6?, is just my document? where I can find documentation about this.

For both endpoints I am using JSONP.


回答1:


Use gid= e.g :

https://spreadsheets.google.com/tq?key=0Ao_WaOWBqWmjdGRZV3dxdW1sdXhaeUs0cko5ZEVldEE&gid=0&tq=select%20A

I read that #gid and od6 are not connected, and the only way to get the od6 that links to the #gid, is to loop through all the #gid values to find the matching sheet.

I suspect there is no way to add "gid" into the query string, as there is no way to merge data from more than one source with the query, or none that I have seen.




回答2:


To use a gid did not work for me, I used:

http://spreadsheets.google.com/feeds/worksheets/MY_KEY/public/basic?alt=json-in-script

To get a list of worksheets and then with the response, I searched in it the title of my spreadsheet and get the id which is od6, od4, etc.



来源:https://stackoverflow.com/questions/20361667/google-spreadsheet-select-worksheet-with-jsonp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!