Google spreadsheets with multiple sheets

How to get feeds from multiple sheets using google spreadsheet feedsapi? Below the URL selects feeds only from the first sheet. In mine spreadsheetI have 3 work sheets, and I also want to get the data of the remaining sheets.

https://spreadsheets.google.com/feeds/list/XXXXMYKEYXXXX/od6/public/values?alt=json-in-script

How to get them?

I tried to do this without success:

https://spreadsheets.google.com/feeds/list/XXXXMYKEYXXXX/od7/public/values?alt=json-in-script

Note od7insteadod6

UPDATE URL for the spreadsheet feed https://spreadsheets.google.com/feeds/list/1c53H0piyduOV6zRwS54A7MDZ3SooJOmj4O52Xd0dyIA/od6/public/values?alt=json-in-script

The spreadsheet has TopicA, TopicB, TopicCsheets. The feed response contains only information TopicA.

+4
source share
3 answers

Per API Google Spreadsheets:

URL- , , . , = "http://schemas.google.com/spreadsheets/2006#tablesfeed". href URL- . .

, GET URL- :

GET https://spreadsheets.google.com/feeds/worksheets/key/private/full

URL- , , , . , od6 , .

+3

suman j, , , , jQuery.

JSON , URL- JSON, URL-, . ajaxStop , .

$(function(){
    var feedurl_start = "https://spreadsheets.google.com/feeds/";
    var feedkey = "1c53H0piyduOV6zRwS54A7MDZ3SooJOmj4O52Xd0dyIA";

    $.getJSON(feedurl_start+"worksheets/"+feedkey+"/public/basic?alt=json", function(sheetfeed) {
        $.each(sheetfeed.feed.entry, function(k_sheet, v_sheet){
            var sheeturl = v_sheet.link[0]["href"]+"?alt=json";
            sheeturl = sheeturl.replace("basic", "values");
            var sheet_title = v_sheet.content["$t"]; // to know which sheet you're dealing with
            console.log(sheet_title);
            $.getJSON(sheeturl, function(sheetjson){
                console.log(sheetjson);
            });
        });
    });
});

// Since you're making multiple AJAX calls, use ajaxStop
// to do whatever you need to do AFTER everything is loaded
$( document ).ajaxStop(function() {
    // now all your data is loaded, so you can use it here.
});
+1

Source: https://habr.com/ru/post/1547824/


All Articles