Summary of 0.

Microsoft has added support for writing custom functions in JavaScript to Excel.

Example 1.

For example, add 42 to the sum of two numbers:

We can use JavaScript to write:

function ADD42(a, b) {
    return a + b + 42;
}
Copy the code

Then, just like with any other Excel built-in function, call it like this:

= CONTOSO. ADD42 (1, 2)Copy the code

2. Precautions

This feature is not yet available in the official release.

Custom [JavaScript] functions are now available in Developer Preview on Windows, Mac, and Excel Online

You can install Office (build 9325 on Windows or 13.329 on Mac) and add Office Insider (this feature is disabled by default and will only be enabled if you add Insider).

Clone the repo OfficeDev/ excel-custom-functions on GitHub, use the Readme file to experience this functionality, or write JavaScript Custom Functions directly in Excel.

3. Known problems

  • Mobile version is not supported
  • Currently you need to rely on hidden browser processes to support asynchronous custom functions
  • Some functions need to be recalculated automatically when unrelated data in Excel changes. JavaScript is not currently supported
  • Debugging of asynchronous functions is supported only on The Windows platform

4. Reference links

  • Create custom functions in Excel (Preview) | Microsoft Docs
  • Microsoft Adds Support for JavaScript Functions in Excel
  • OfficeDev/Excel-Custom-Functions – GitHub