How to refresh a sheet's cell value in Google Apps Script

后端 未结 5 1284
囚心锁ツ
囚心锁ツ 2020-12-16 15:02

I\'m experimenting with Blockspring which provides a Google Sheets add-on which can, for example, run a function which returns data from a webservice e.g.

=B         


        
5条回答
  •  臣服心动
    2020-12-16 15:34

    The flush() method can be used. Also see answers provided by others.

    Documentation

    SpreadsheetApp.flush();
    

    Quote from the documentation:

    Applies all pending Spreadsheet changes

    If there were no changes to the spreadsheet, but you want to force formulas to recalculate, you will need to make a change, and then use SpreadsheetApp.flush();

    For example, you could get the value from cell A1, then set the same value to cell A1. So, there is no chance of losing data because you are getting and setting the same value. The change allows. SpreadsheetApp.flush(); to recalculate all the formulas.

    The documentation has some information on optimization: Google Sheets Custom Function Optimization

提交回复
热议问题