查询Google试算表的特定工作表 [英] Query specific sheets of a google spreadsheet
问题描述
我尝试使用Google试算表做为临时资料库。我按照下面的教程中的说明操作,一切正常。
获取我下面用于引用的数据的jquery
我想知道是否可能(使用相同或相似的代码),假设在电子表格一次只能查询一个。例如,你可以运行下面的代码,但只是为第4页。
我已经尝试从网址(即#gid = 1)添加表ref#数字代码的结尾是
变成
但这不起作用,代码
任何帮助都非常感谢
/ p> < script type =text / javascript>
$(document).ready(function(){
//源文件是https://docs.google.com/spreadsheet/ccc?key = 0Ak0qDiMLT3XddHlNempadUs1djdkQ0tFLWF6ci1rUUE
$ (function listBooks(){
$ .getJSON(https://spreadsheets.google.com/feeds/list/0Ak0qDiMLT3XddHlNempadUs1djdkQ0tFLWF6ci1rUUE/od6/public/values?alt=json-in-script&callback =?,
function(data){
$('div#book-list')。append('< ul class =items> ; / ul>');
$ .each(data.feed.entry,function(i,entry){
var item ='< span style = display:none>'+ entry.id。$ t +'< / span>';
item + ='< img src =http://covers.openlibrary.org / b / isbn /'+ entry.gsx $ isbn。$ t +'-S.jpg/>';
item + ='< span class =meta> ; a href =http://www.worldcat.org/isbn/'+ entry.gsx $ isbn。$ t +'>'+ entry.title。$ t +'< / a>';
item + ='< br />作者:'+ entry.gsx $作者。$ t;
if(entry.gsx $ notes。$ t){
item + ='< br />说明:'+ entry.gsx $ notes。$ t;
}
$('。items')。append('< li>'+ item +'< / span>< / li>');
});
});
});
});
< / script>
好,我有一个解决方案,
特定工作表的ID似乎是/ od6 / part的网址,od6是给予第一个,默认,工作表的默认名称
在上面的博客中有一个例子,你需要。它似乎没有一个干净的逻辑,但更改它将吐出特定表的数据,因此它工作。
I am attempting to use a google spreadsheet as a temporary database. I have followed the instructions at the folowing tutorial and everything is working fine
The jquery that gets the data I have copied below for ref
I wondered if it would be possible (using the same or similar code), assuming there are multiple sheets within the spreadsheet to query just one at a time. So for example you could run the below code but only for say sheet 4.
I have tried adding sheet ref # from the web URL (i.e #gid=1) at the end of the numeric code so
becomes
but this does not work, the code only seems to loop through the first sheet
Can anyone advise on this?
Any help is much appreciated
<script type="text/javascript">
$(document).ready(function() {
//source file is https://docs.google.com/spreadsheet/ccc? key=0Ak0qDiMLT3XddHlNempadUs1djdkQ0tFLWF6ci1rUUE
$(function listBooks() {
$.getJSON( "https://spreadsheets.google.com/feeds/list/0Ak0qDiMLT3XddHlNempadUs1djdkQ0tFLWF6ci1rUUE/od6/public/values?alt=json-in-script&callback=?",
function (data) {
$('div#book-list').append('<ul class="items"></ul>');
$.each(data.feed.entry, function(i,entry) {
var item = '<span style="display:none">' + entry.id.$t + '</span>';
item += '<img src="http://covers.openlibrary.org/b/isbn/' + entry.gsx$isbn.$t + '-S.jpg"/>';
item += '<span class="meta"><a href="http://www.worldcat.org/isbn/' + entry.gsx$isbn.$t + '">' + entry.title.$t + '</a>';
item += '<br/>Author: ' + entry.gsx$author.$t;
if (entry.gsx$notes.$t) {
item += '<br/>Description: ' + entry.gsx$notes.$t;
}
$('.items').append('<li>' + item + '</span></li>');
});
});
});
});
</script>
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
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.
这篇关于查询Google试算表的特定工作表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!