See below the function that converts the active Google spreadsheet to a .xlsx file. The script saves the file in Google Drive.
function downloadAsXlsx() {
var spreadSheet = SpreadsheetApp.getActiveSpreadsheet();
var ssID = spreadSheet.getId();
Logger.log(ssID);
var url = "https://docs.google.com/spreadsheets/d/"+ssID+"/export?format=xlsx";
var params = {method:"GET", headers:{"authorization":"Bearer "+ ScriptApp.getOAuthToken()}};
var response = UrlFetchApp.fetch(url, params);
DriveApp.createFile(response);
}
If you replace the ssID in the above URL with the actual file ID of the active Google spreadsheet and copy and paste the URL into the browser, the active spreadsheet is downloaded “automatically”. This is exactly what I need to add the above script.
My question is how to change and / or expand the function above so that the file is instead downloaded to the local download folder by default?