3
votes

this morning I noticed that the current way we used to export our Google Spreadsheets as Open Office (ods) documents does not work anymore with the new spreadsheet version. We were requesting the file's metadata via the Google Drive API and used the returned exportLinks. For old version spreadsheets the result was something like this:

exportLinks: {
  'application/pdf': 'https://docs.google.com/feeds/download/spreadsheets/Export?key=someid&exportFormat=pdf',
  'application/x-vnd.oasis.opendocument.spreadsheet': 'https://docs.google.com/feeds/download/spreadsheets/Export?key=someid&exportFormat=ods',
  'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': 'https://docs.google.com/feeds/download/spreadsheets/Export?key=someid&exportFormat=xlsx'
}

So we got a PDF, XLSX and ODS link. But in the new version we get a CSV instead of an ODS link:

exportLinks: {
  'text/csv': 'https://docs.google.com/spreadsheets/export?id=someid&exportFormat=csv',
  'application/pdf': 'https://docs.google.com/spreadsheets/export?id=someid&exportFormat=pdf',
  'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': 'https://docs.google.com/spreadsheets/export?id=someid&exportFormat=xlsx'
}

According to the documentation the export links for a spreadsheet should be Microsoft Excel (xlsx), Open Office sheet (ods) and PDF. I'm currently not sure if the documentation is not up to date or I'm doing something wrong with the API. My current workaround was to hardcode the link to the ODS export. The download is still working, the download link is just missing from exportLinks object.

P.S.: To make it more clear. Everything is still working fine with spreadsheets that are not yet updated to the new spreadsheet version.

1
Maybe worth opening an issue within google-drive-api and see if google can copy and paste some code over (hope it is that easy). - eddyparkinson
I've opened issue 3713 on apps-api-issues. - astrada

1 Answers

0
votes

I solved this problem with

download_url = drive_file[u'exportLinks'][u'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']
  # xlsx shold be changed to ods
  download_url = download_url.replace('xlsx','ods')

but I don't know how much time it will work