0
votes

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' });
2
if i use mimeType as 'application/vnd.ms-excel' then getting The requested conversion is not supportedSumathi
try application/vnd.openxmlformats-officedocument.spreadsheetml.sheetpinoyyid
@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
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

2 Answers

1
votes

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