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);
// save to drive
DriveApp.createFile(response);
}
If you replace the ssID in the URL above by the actual file id of the active Google Spreadsheet and copy and paste the URL in the browser, the active spreadsheet is downloaded "automatically". That is exactly what I need to be added to above script.
My question is how to change and/or extend the function above so that the file is instead downloaded to the local machine in the default download folder?