How To Download / Export Sheets In Spreadheet Via Google Apps Script

前端 未结 4 1720
故里飘歌
故里飘歌 2021-01-01 07:46

The task is to automate the manual process accomplished by the menu option \"File | Download As | Plain Text\"

I want to be able to control the saved file name, whic

4条回答
  •  执念已碎
    2021-01-01 08:23

    This app script returns a file for download instead of web page to display:

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

提交回复
热议问题