0
votes

I need to send a google spreadsheet file as an .xlsx by email attachment. I know this can be done using UrlFetchApp, but my organization is blocking this service for security reasons, so I can only use DriveApp and MailApp.

My Code:

function testsendxlsx() {
 var spreadsheetId = "id_here" 
 var file          = DriveApp.getFileById(spreadsheetId);
 var blob = file.getAs(MimeType.MICROSOFT_EXCEL);
 var fileName = "testing" + '.xlsx';
 var receipient = "email_here"
 var subject = "testing .xlsx"
 var emailbody = "something"

 MailApp.sendEmail(receipient, subject, emailbody, {attachments: blob});
}

I get this error:

Converting from application/vnd.google-apps.spreadsheet to application/vnd.openxmlformats-officedocument.spreadsheetml.sheet is not supported. (line 6, file "Code")

Any ideas how this could be done?

1

1 Answers

-1
votes

As of now, there is no way to do what you want.

Ideally, you could use the Advanced Drive Services and call the Drive.Files.export endpoint, however, there is an issue with it right now.

There is already a bug reported to address this here.

You can subscribe to this by clicking on the star ☆ next to the Issue number in order to receive updates and to give more priority to the bug.