Excel supports custom functions using JavaScript
Microsoft recently announced support for creating custom functions directly in Excel using JavaScript, currently in developer preview. This feature goes beyond the scope of the existing Microsoft Office JavaScript APIs, a set of APIs limited to building plug-ins or web applications that interact with the object model in Office applications.
The Microsoft Office team has created a GitHub code repository that demonstrates how to create custom functions in Excel using JavaScript. The sample code base divides the functions into four categories.
Custom functions have no associated user interface, and developers should not try to manipulate the DOM. The development team would like to remove the HTML files used for custom function initialization before the final release of this feature.
Support for modern JavaScript features such as Promise allows developers to define custom functions as synchronous functions for quick evaluation, or as asynchronous functions for calculations that may take a while to complete. Streams are an asynchronous Promise that can return values multiple times, not just once, which is an option for Excel custom JavaScript functions.
Excel's JavaScript also makes use of the Chakra JavaScript engine used by Microsoft's Edge browser.
Custom functions are currently only supported on Windows, Mac, and Excel Online for the Developer Preview version of Excel, and do not apply to Excel on mobile devices or production versions of Excel.
This feature brings some functionality similar to Google Sheet, which already supports custom functions using JavaScript.
TypeScript users can also write custom JavaScript functions, except that they have to convert to JavaScript first. Microsoft does not intend to provide direct TypeScript support in Excel.
Although there is no official product release date for customizing JavaScript functions in Excel, users interested in this feature should try this preview release and provide feedback to the Office team.
View original in English:Microsoft Announces JavaScript Support for Excel Custom Functions