It seems that @Christiaan Westerbeek's answer is a slick, but a year has passed since its publication, and I think that in the script that he gave above, there should be a slight modification.
var url = file.exportLinks[MimeType.MICROSOFT_EXCEL];
Something is wrong with this line of code, it is possible that exportLinks now depreciating. When I executed his code, he gave an error for the following effect:
TypeError: Unable to read property " application/vnd.openxmlformats-officedocument.spreadsheetml.sheet " from undefined.
The workaround is as follows:
The URL in the above line of code is basically a βdownload as xlsxβ URL, which you can use to directly download the spreadsheet as an xlsx file, which you get from File> Download as > Microsoft Excel (.xlsx)
This is the format:
https://docs.google.com/spreadsheets/d/<<<ID>>>/export?format=xlsx&id=<<<ID>>> << < https://docs.google.com/spreadsheets/d/<<<ID>>>/export?format=xlsx&id=<<<ID>>> << < https://docs.google.com/spreadsheets/d/<<<ID>>>/export?format=xlsx&id=<<<ID>>> where https://docs.google.com/spreadsheets/d/<<<ID>>>/export?format=xlsx&id=<<<ID>>> β should be replaced with the identifier of your file.
Check here to easily understand how to extract the identifier from the URL of your Google page.
source share