Trigger spreadsheet recalculation from script

前端 未结 2 1982
萌比男神i
萌比男神i 2021-01-28 09:48

I have a script that can delete one or more named ranges. However, the sheet does not recompute either after the script finishes or after a flush command is given. The only way

2条回答
  •  南方客
    南方客 (楼主)
    2021-01-28 10:07

    If the action taken upon the spreadsheet has no impact on any formulas, then there will be no recalculation. Deleting a named range, for example, has no recalculation impact unless that named range is referenced in a formula. (And if that's the case, then the spreadsheet was probably broken by the deletion.)

    Spreadsheet.flush() does not force recalculation - it's only supposed to write pending changes to the spreadsheet. (And if that change doesn't affect formulas... you get the idea.)

    The net result is that you're left with the solution you describe; you need to update a cell that's involved in calculations. Replacing a formula will do. Sorry, no magic incantation for this.

提交回复
热议问题