everyone! I am working with App Javascript into a Google Sheet and I need to run a script to download the Worksheet to my computer with extension .xlsx I am so close, but it is missing the end.
function exportExcel() {
/*Get your Spreadsheet */
var ss = SpreadsheetApp.openById("sheetID");
//*Create URL to Export as xlsx
var url = "https://docs.google.com/feeds/download/spreadsheets/Export?key=" + ss.getId() + "&exportFormat=xlsx";
var params = {
method: "get",
//*add authorization to get the file
headers: { "Authorization": "Bearer " + ScriptApp.getOAuthToken() },
muteHttpExceptions: true
};
//* with an http query get the blob file
var blob = UrlFetchApp.fetch(url, params).getBlob();
//* sets the file extension
blob.setName("BCI Scorecard.xlsx")
blob.name = "BCI Scorecard.xlsx"
blob.lastModified = new Date()
console.log(blob)
//Send Mail with attachments
MailApp.sendEmail("email", "Scorecard", "This mail contains .XLSX file attached",
{ attachments: [blob] });
}
With this code, I am able to send the file attached to my email (made just for test). But what I really want is to save it in a designed path in my computer.
What is missing? I know I am close.
Thank you, Breno