简体   繁体   English

GAS-执行超时

[英]GAS - Execution time-out

I have a spreadsheet that needs to 'setValue' to about 2000 rows. 我有一个电子表格,需要将“ setValue”设置为大约2000行。 The problem is, after awhile, I get time-out. 问题是一段时间后,我超时了。

So I'm looking for a solution to split up the job. 因此,我正在寻找解决方案以分散工作。

I'm thinking of creating a time-based trigger, possibly to start off where the last row or timeout ended. 我正在考虑创建一个基于时间的触发器,可能从最后一行或超时结束的地方开始。 But I can't figure how to get trigger unique ID. 但是我不知道如何获取触发器的唯一ID。

function triggerList() {

  ScriptApp.newTrigger('populateList')
   .timeBased()
   .after(5 * 60 * 1000) // run every 5 mins. Script will time-out.
   .create();

}

function deleteTrigger() {
 // delete the above trigger
 var triggers = ScriptApp.getProjectTriggers();

 for (var i = 0; i < triggers.length; i++) {
   Logger.log(triggers[i]);
 }
}

There is a similar topic on this but i don't quite understand. 有一个与此类似的话题,但我不太明白。
What happens when I "sleep" in GAS ? 当我在GAS中“睡眠”时会发生什么? (execution time limit workaround) (执行时间限制解决方法)

Anyone has suggestions, workarounds? 有人有建议,解决方法吗?

Put all of your data into a two dimensional array first, then set all the values at once. 首先将所有数据放入二维数组,然后立即设置所有值。 Each inner array is a row, each element of each inner array is a cell in a new column. 每个内部数组都是一行,每个内部数组的每个元素都是新列中的单元格。

Set Values Documentation 设定值文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM