0

我創建了一個類似於Google Apps腳本Help Center上提供的示例的儀表板。它包含用於過濾包含數據的電子表格的控件。我想在儀表板上添加一個選項,該選項允許用戶將過濾後的視圖導出到新的CSV文件或Google Sheets文件,該文件將保存在其雲端硬盤中,但我不知道如何執行此操作。有什麼建議麼?Google Apps腳本:將儀表板導出爲CSV

回答

0

下面是從谷歌教程的代碼片段:

function saveAsCSV() { 
    // Prompts the user for the file name 
    var fileName = Browser.inputBox("Save CSV file as (e.g. myCSVFile):"); 

    // Check that the file name entered wasn't empty 
    if (fileName.length !== 0) { 
    // Add the ".csv" extension to the file name 
    fileName = fileName + ".csv"; 
    // Convert the range data to CSV format 
    var csvFile = convertRangeToCsvFile_(fileName); 
    // Create a file in the Docs List with the given name and the CSV data 
    DocsList.createFile(fileName, csvFile); 
    } 
    else { 
    Browser.msgBox("Error: Please enter a CSV file name."); 
    } 
}* 

查看full tutorial and code here