1

I am trying to create and download a spreadhsheet with google apps script. I create a file

const newDocument = SpreadsheetApp.create("docname");

how can I download the file in xlsx or csv formatting to my machine ? Thank you in advance.

Nane Petrosyan
  • 553
  • 1
  • 7
  • 19
  • Does placing the document in drive and let it sync to your machine work for you? – Thum Choon Tat Feb 03 '21 at 10:45
  • @ThumChoonTat no ( I need to download the file I create in script. Maybe there is a way to open a download url or something ? – Nane Petrosyan Feb 03 '21 at 10:49
  • @NanePetrosyan you need to produce an event in order to download the file from the browser. You can't just download it. You need to click somewhere and do it. Here is a [so](https://stackoverflow.com/a/17460815/11225291) example on how to do that. And [here](https://tanaikech.github.io/2020/11/23/downloading-active-sheet-in-google-spreadsheet-as-csv-and-pdf-file-by-clicking-button/) is another alternative to create a sidebar with 2 buttons that will allow you to download the file. – Marios Feb 03 '21 at 11:07
  • 1
    Check also this question which is very close to what you want. [Initiate a download from google apps script](https://stackoverflow.com/questions/20281272/initiate-a-download-from-google-apps-script) – Marios Feb 03 '21 at 11:11

0 Answers0