我目前正在使用此脚本一次完成整个过程
function Script(){
// Gets Temp Sheet
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sh = ss.getSheetByName("Temp");
// Change file name
ss.rename(sh.getRange('Q4').getValue());
// Hide Sheet "Temp"
sh.hideSheet();
// Paste as values dates from sheet Temp
var range ="AL3:AL5";
sh.getRange(range).copyTo(sh.getRange(range), {contentsOnly:true})
// Hides blank rows in sheets 1,2,3
Hide();
// Creates the File in Drive
var sheetId = ss.getId();
var folder = DriveApp.getFolderById("ID"); // The File is stored in this folder
var name = ss.getName() + ".xlsx"; // The name of the new file
var url = "https://docs.google.com/spreadsheets/d/" + sheetId + "/export?format=xlsx&access_token=" + ScriptApp.getOAuthToken();
var blob = UrlFetchApp.fetch(url).getBlob().setName(name); // Modified
folder.createFile(blob);
Reset();
}
/*
After the file is generated
*/
function Reset() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName('Temp');
// Unhide Sheet "Temp"
sheet.showSheet();
// Resets Sheet Temp
sheet.getRange('A1:AI').clearContent();
sheet.getRange('AL3').setFormula('=AL1');
sheet.getRange('AL4').setFormula('=WORKDAY(AL3,1)');
sheet.getRange('AL5').setFormula('=WORKDAY(AL4,1)');
// Reset the file name
ss.rename('_'+'TEMPLATE');
// Set the cursor to move to Temp
SpreadsheetApp.setActiveSheet(ss.getSheetByName('Temp'))
// Unhides Rows from sheets 1,2,3
Unhide();
}
我的问题是,在结束进程之前,它已经运行了Reset()函数;然后将我的文件保存在hide()之前;函数结束其过程
如何暂停或解决此问题?
我具有红色的flush函数,但是,正如我所看到的,flush是在循环中使用,或者当您具有if语句时,我不知道如何应用于此示例代码
谢谢!