3

I am trying to pass the Google Spreadsheet ID (Where the file is in Google Drive with Every one view option) to the Google Drive Export API and download the file to local directory. As I need to download the file as xls or xlsx. If I use mimeType as "application/vnd.google-apps.spreadsheet" and getting an error as "The requested conversion is not supported". Same error message would be return to execute the same API using Google's API Explorer window as well. If I change the mimeType as "text/csv" then its working fine. Please help me whats the wrong with the mimeType which I used in the below code.

  const drive = google.drive({version: 'v3', auth});
  const res =  drive.files.export({
     fileId: '1YHO6KuXuUdTQmUgPTJkYNiLrkQBWejDREZLEK62ZT_Q',
     mimeType: 'application/vnd.google-apps.spreadsheet',
     responseType: 'stream' });
5
  • Use google.com/…
    – pinoyyid
    Oct 13, 2018 at 12:03
  • if i use mimeType as 'application/vnd.ms-excel' then getting The requested conversion is not supported
    – Sumathi
    Oct 13, 2018 at 12:30
  • 1
    try application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
    – pinoyyid
    Oct 13, 2018 at 17:10
  • @pinoyyid, i have tried this mimeType "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" but response.data is corrupted so i can not able to export the google spreadsheet content to other xls/x;sx file. Below are the code snippets which i have tried: fs.writeFileSync('./testfolder/test.xlsx', res);
    – Sumathi
    Oct 15, 2018 at 4:00
  • It's probably not corrupt, but you are not writing it to file correctly. Check what is being downloaded and also what is in your "corrupted" file.
    – pinoyyid
    Oct 15, 2018 at 9:04

1 Answer 1

2

Replace application/vnd.google-apps.spreadsheet with application/vnd.openxmlformats-officedocument.spreadsheetml.sheet. Works like a dream.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.