Google-sheets – How to create a function to “Save as” CSV file

google sheetsgoogle-apps-script

Here is my situation, I have Google sheet with just one sheet, so I allow the user to enter data there by just filling each row, ok, I have created a little script to add and extra custom menu, just named CUSTOM MENU, just next to the Help and also under the CUSTOM MENU a submenu, named DOWNL A CSV, I want when the useselectsct the DOWNL A CSV, so this will take the data from the Google sheet that is named "mynewsheet" and of course the only sheet I have is sheet1 and then download the CSV file as MYNEWSHEET.CSV instead of MYNEWSHEET-SHEET1.CSV and also if possible to download it to a specific folder in my local computer, example if it is possible to E:\CSV, so as a result I will get as E:\CSV\MYNEWSHEET.CSV", if is not possible to be in E:\CSV, then it will fine in default folder(which is the download folder in the local pc), I just need the script to allow me to download as CSV with the name I mentioned, can anyone help how to do this thanks in advance

Best Answer

This can't be done by using server side code alone as Google Apps Script can't download files to the user device.

One alternative is to use the HTML Service to create a user interface with client-side code that makes the download.

Related questions on Stack Overflow