问题
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.
回答1:
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()
来源:https://stackoverflow.com/questions/26925055/how-can-i-pause-the-execution-of-code-in-google-script-until-the-entire-spreadsh