如何在Google脚本中暂停执行代码,直到整个电子表格被更新? [英] How can I pause the execution of code in google script until the entire spreadsheet gets updated?

查看:220
本文介绍了如何在Google脚本中暂停执行代码,直到整个电子表格被更新?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含大量数据和公式的电子表格。我将电子表格中的特定单元格值导入Google脚本。但是,由于单元格没有使用最近的修订版进行更新,因此该脚本将采用先前的值。现在我已经在脚本中给睡眠暂时停止脚本运行,以等待电子表格更新。我不确定未来睡眠时间是否充足,电子数据表中的数据会不断增加。

我想知道是否有办法检查电子表格的状态(更新?更新?等)。我将只在电子表格更新时运行脚本。



任何帮助将不胜感激。这是我认为在逻辑,代码,触发器等方面挣扎后完成任务的最后一个问题。

正如Anees在评论中提到的那样,flush()命令就是你要找的东西。

  SpreadsheetApp.flush(); 

https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet-app#flush()


I have a spreadsheet with lots of data and formulae. I am importing a particular cell value from spreadsheet into the google script. However since the cell is not updated with a recent revision, the script is taking the previous value. For now I have given "sleep" in script to temporarily stop the script from running so as to wait for the spreadsheet to get updated. I am not sure if the time that gave in sleep is sufficient in future with the data in spreadsheet increasing continuously.

I would like to know if there is a way to check the status of spreadsheet (updated? updating? etc). I will only run the script when the spreadsheet is updated.

Any help will be highly appreciated. This is the last issue that I reckon could be to finish my task after being struggled in logic, code, triggers etc.

解决方案

As Anees mentioned in the comments, the flush() command is what you are looking for.

SpreadsheetApp.flush();

https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet-app#flush()

这篇关于如何在Google脚本中暂停执行代码,直到整个电子表格被更新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆