我目前有一個谷歌電子表格,將創建一個CSV文件,並保存在我的谷歌驅動器,當觸發熄滅。我無法弄清楚如何在創建新的csv文件之前刪除現有的csv文件。當它保存新版本時,它只是製作另一個副本。我需要覆蓋以前的文件(或刪除舊的然後導出/寫入新的版本。)谷歌應用程序腳本導出和替換CSV文件
這裏是腳本來創建CSV文件:
function saveAsCSV() {
// Prompts the user for the file name
var fileName = ("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
DriveApp.createFile(fileName, csvFile);
}
else {
Browser.msgBox("Error: Please enter a CSV file name.");
}
}
我怎麼能覆蓋CSV文件每次腳本觸發器都會熄滅?
的可能的複製[如何刪除/使用覆蓋CSV文件谷歌應用程序的腳本?](http://stackoverflow.com/questions/14965442/how-to-delete-overwrite-csv-file-using-google-apps-script) –
我試着用這個解決方案,並不能得到它爲我工作 – cgrouge