Use the Spreadsheet standard functions in Scripts?

2020-04-10 03:38发布

问题:

When I'm scripting and want to use a standard function e.g. WEEKNUM, is this possible directly or do I have to trigger the Formula into another field via setFormula(formula) and afterwards read the content from the related cell?

回答1:

The approach you describe is indeed possible but not efficient at all because it needs multiple calls to spreadsheet read / write which are relatively slow...

Using Native spreadsheet functions in JavaScript (Google-Apps-Script) is otherwise not possible.

Try to find an equivalent in JavaScript instead.

If you don't know how to get some result in JS, a search on Google will in most case bring an answer.

For your example of WEEKNUM, a search would return this result for example