2
votes

I'm looking for a way to either:

a) replace "File" > "Download as..." > "Microsoft Excel (.xlsx)" in Google Spreadsheet in such a way that when I click on "Microsoft Excel (.xlsx)" it asks me for the name of the file that I want to save (i.e.: like a typical "Save as..." menu entry).

b) if it's not possible to replace the standard menu entry, I would like at least to add another menu entry in another menu which behaves like described above.

Even though I haven't been able to write a script that lets me replace an existing menu entry, I've managed to write a script that adds an additional menu.

Is it possible to accomplish "a"?


Another problem now is that I can't seem to find a way to replicate the behaviour of "File" > "Download as..." > "Microsoft Excel (.xlsx)".

I've found other posts in which it's described how to write Google Scripts in order to do something similar (e.g.: create a backup of a spreadsheet in Google Drive in a specific format, or send it via GMail to a specific address).

Actually, after reading "Can I download file from URL link generated by google apps script" I'm not even sure it's possible.

Note that you cannot download per se, since you have no access to your PC's resources (e.g. file system) from apps-script. The file is still in "the cloud"... in this case, it's been copied from the web site it was on, into Google Drive. If you're running the Drive app, though, the file will now sync to your PC.

Is there any way to do that?


Thanks in advance.

1
you actually answered your own question yourself... and there is indeed no way to change the default menus in a Google document.Serge insas
How about the second point? Is it possible to replicate the behaviour of "File" > "Download as..." > "Microsoft Excel (.xlsx)"?Fergus Incoronato
As you mentioned: "...you can not download per se..." you can just use the drive.app workaround.Serge insas

1 Answers

1
votes

The only way I achieved download of a file from the spreadsheet is by writing completely separate script which accessed my original spreadsheet by document id, generated a file and downloaded it like this:

function doGet(){
    var outputDocument = DocumentApp.create('Some csv'); 
    var content = getCsv();
    var textContent = ContentService.createTextOutput(content);
    textContent.setMimeType(ContentService.MimeType.CSV);
    textContent.downloadAsFile("4NocniMaraton.csv");
    return textContent;
}

Then I had to publish the App and get a link for it. That link I placed in one of the sheets in the original spreadsheet, which I used as a data download link. Other then this I didn't find a way to work the security issues around.