【发布时间】:2021-10-27 01:14:04
【问题描述】:
我一直在尝试导出我的spreadsheet 的全部内容。该代码运行良好,但显示一条错误消息,指出超出了最大执行限制。根据我的研究,最长执行时间仅为 6 分钟。我对此很陌生,但仍在尝试弄清楚。您能帮我确定一个可能的解决方案吗?
这是我目前正在使用的code...
function PrintMultiple() {
const srcSs = SpreadsheetApp.getActiveSpreadsheet();
const sheet = srcSs.getSheetByName("TEMPLATE");
const values = sheet.getRange("C2").getDataValidation().getCriteriaValues()[0].getValues().flat().filter(String);
const dstSs = SpreadsheetApp.create("tempSpreadsheet");
SpreadsheetApp.getActive().toast("About to take some action... Please wait...");
values.forEach(v => {
sheet.getRange("C2").setValue(v);
SpreadsheetApp.flush();
const tempSheet = sheet.copyTo(srcSs);
const range = tempSheet.getDataRange();
range.copyTo(range, {contentsOnly: true});
tempSheet.getRange("B2:2").clear().clearDataValidations();
tempSheet.getDrawings().forEach(e => e.remove());
tempSheet.deleteColumn(1);
tempSheet.deleteRow(1);
tempSheet.deleteRow(2);
tempSheet.deleteRow(3);
tempSheet.copyTo(dstSs);
srcSs.deleteSheet(tempSheet);
});
dstSs.deleteSheet(dstSs.getSheets()[0]);
}
【问题讨论】:
-
虽然我不确定您的实际电子表格,但我提出了修改后的脚本以降低流程成本作为答案。你能确认一下吗?如果这不是您问题的直接解决方案,我深表歉意。
标签: google-apps-script google-sheets google-sheets-api