0
votes

We've previously been getting exports from the google spreadsheet api using the following url

https://spreadsheets.google.com/feeds/download/spreadsheets/Export?key=spreadsheetID&exportFormat=csv&gid=gid

When Google introduced the new Sheets this URL did not work for them, though did continue to work for old style spreadsheets. As a result we've been using the Google drive API to get the new style sheets, but this has some limitations as you must get the whole spreadsheet instead of an individual worksheet and it does not support CSV(your exports must be Excel).

Though after reading the following question : Is an API available for the new Google sheets (spreadsheets)? It looks like the new sheets are supported despite no information about it in the api documentation.

After digging through the response I found the new sheets have an export link included as field in the format:

https://docs.google.com/spreadsheets/d/spreadsheetID/export?format=csv&gid=gid

Which works great. The problem is that the old sheets don't work with the new URL andthere is no field specifying that it is a new sheet and it must be inferred from the existence of the field.

So I'm wondering if there is a better way to determine if I'm dealing with an old or new sheet and if this is a reliable way to get spreadsheet data as it doesn't seem to be documented.

Thanks!

1
When you open the spreadsheet, the URL for new and old style sheets is different - not sure if that helps you.eddyparkinson

1 Answers

0
votes

Google spreadsheet API (GData style) works the same for both old and new style sheets.

Possible issues:

1) non public sheets require OAuth2

2) The sheet id is not the GID. You need the GData style sheet ID to get the sheet. So it needs an API call to get the mappings from sheet name to sheet id

3) The raw format of the data is XML