Excel Adds JavaScript and Power BI Support
dev.office.com
dev.office.com
/**
* adds 42 to the input number
* @param a the first number to be added
* @param b the second number to be added
*/
function ADD42(a: number, b: number): number {
return a + b + 42;
}
[1] https://docs.microsoft.com/en-us/office/dev/add-ins/excel/cu...Actually, every other language in the world besides JavaScript should be supported.
In theory, you could embed all of the metadata in JSDoc + TS annotations.
It would add to complexity if you introduce a compilation step before executing them in JS runtime, especially when you are targeting multiple platforms.
As other commenters have mentioned, we want to stay flexible for everyone, whether or not they use TypeScript. We'll provide support to make the TypeScript development experience great, like type definition files. You can compile any TS files to JS at development/deployment time (admittedly a little more legwork for your dev environment, yes).
Finally, we'll be releasing an update for Script Lab[1] to support custom JavaScript functions soon. And since Script Lab supports TS we've used exactly the model you suggest above to define the function metadata in Script Lab.
-Michael
[1] https://github.com/OfficeDev/script-lab/blob/master/README.m...
That announced Azure ML feature is optimized for machine learning models (in terms of the tools/deployment/runtime we've provided), so even though it will work for any Python functions it might not be exactly what you're asking for. Also, depending on your specific use case, you may or may not need client-side execution (Azure ML functions run in the cloud today). I can't share specifics on other unannounced features, but Azure ML functions are only our first foray in this space: we think custom functions running in the cloud are very important for many different use cases in Excel.
Also, note that on the JavaScript side, the language choice isn't something new for Excel or Office: for example, there's a public ecosystem of add-ins that automate Excel via JavaScript today[2]. Custom functions are just the latest way we've enabled for extending Excel as part of an add-in[3].
[1] https://dev.office.com/blogs/azure-machine-learning-javascri... [2] https://appsource.microsoft.com/en-us/marketplace/apps?produ... [3] https://docs.microsoft.com/en-us/office/dev/add-ins/excel/ex...
I haven't used it myself yet but am planning on using it in a project I'm working on currently. I'm building a questionnaire creator that can auto merge into docx files by using comments as merge keys (you highlight where you want to merge and leave a comment, then in the web UI where you build the questionnaire, you associate each form field with a comment in the uploaded docx file). At some point I would like to convert this to use the office API, which would enable a lot of cool features for converting a docx form into a questionnaire.
[0] https://msdn.microsoft.com/en-us/office/office365/howto/plat...
There might be additional checks if you package your solution as a proper add-in (it might have to be enabled by an O365 admin).
Right now developers have to sideload the add-in manually. But when the feature ships publicly, the add-in that has the custom JS functions will be deployed to a "catalog". The various Excel platforms (like Excel for Windows, Mac, and Excel Online) will all be able to access that catalog automatically to run the same functions because a pointer to the add-in gets persisted in the xlsx file.
That's a little different from VBA UDFs, which get stored in the file itself. But one advantage of our new model is that it will be way easier for organizations to manage and maintain their JS functions, compared to VBA.
As a result I'm using Python and Jupyter notebooks now, not as friendly as Excel but at least its modern and there are lots of libraries out there to make the platform super powerful.
https://excel.uservoice.com/forums/304921-excel-for-windows-...
Microsoft provide the right tools at the right point in the business lifecycle.
Have you ever been in a company where That Spreadsheet is rebuilt "properly" at great expense by "people who know what they are doing" and then, the first time the business wants a change it takes more than an afternoon and everyone goes back to the spreadsheet again?
Some (most?) people aren't programmers and have no choice. Microsoft lets them be the masters of their own destiny.
I think you failed to move the goalpost away from elitism.
(I guess that's one way to drive new hardware sales, though.)
https://docs.microsoft.com/en-us/office/dev/add-ins/tutorial...
Step 1 in the official Excel Add-Ins tutorial includes installing Node and npm.
Not likely. Given the depth and breadth of its penetration, all the man-millenia that have been spent encoding business rules in Excel, I suspect that in the end Excel will outlive Windows itself, just as COBOL has outlived the mainframe era.
I'd love to see a principled approach to extending Excel, and maybe MS have already done it. There are a lot of ways to extend Excel, and given the MS practice of keeping backwards compatibility alive for decades, none of them is going away any time soon. Could be one of them is actually good. I just today learned about Power Query M, which looks promising.
Also, installing it is not exactly user friendly. Heck, you have to open a terminal to launch it!
however, VBA code is also spaghetti code with global vars and <what not> mixed into it.
Source: I have debugged vba macros in excel before.
This is a huge game-changer and it also introduces the opportunity for enterprising (pun?) software developers to be a lot more valuable to a business by moving core business logic out of VBA into git-managed JS and making it versioned, highly reusable, etc. Going a bit further, I see an avenue to offload heavy compute to servers and create a usable link between Excel and e.g. Cassandra/Spark/HDFS.
You have to appreciate just how fundamental Excel is to businesses to see the size of the opportunity Microsoft just gifted to developers.
> • Calculate math operations, like whether a number is prime.
It saddens me that this is a thing we want Javascript for.
So anyway, now we have XLL, COM, VBA, and Javascript. All of them different but overlapping ways to extend what Excel can do. Am I missing any?
It might be a small comfort, but Javascript is getting arbitrary precision integer support this year:
More realistically, many languages can already be compiled to JS, you might not need wasm.
Example: coinhive monero miner distributed in xls: https://twitter.com/CharlesDardaman/status/99391267580461465...
Since I work with both python and javascript in exactly this dirty moving data around for analysts space (but haven't for long), I'll qualify a bit.
The most important point is that python absolutely brutally dominates the data science space, there are no javascript equivalents to the python ecosystem, it's not even close.
Secondary point is that javascript is much lower level than python in a language sense. Python already has classes built in, reflection, sane typing, just tons of batteries.
Javascript as someone smarter than me said before is lisp with C syntax. It's definitely possible to build a good language out of Javascript by using the right libraries and making decisions on how you're going to implement inheritance etc but it's just tons harder than python or almost any other language which has defaults on these decisions made for you. Guys automating their data flows aren't going to be at the level to make these decisions well but they will run into the same problems they solve and implement their own insane schemes.
I'd much much rather debug amateur VBA or Python than amateur javascript.
I'll give you the batteries included part, but you're missing the critical component here, which is Python's dep mgmt story is terrible. Pyenv seems cool, but it's basically NPM - which is a critical part of what they're trying to do here.
It doesn't have anything like python's built in power of classes, it's not just having a class syntax which is a thin wrapper around prototypes, it's having metaclasses, class decorators, properties, type comparison that works for inheritance, super().
It also doesn't have sane types/casts.
The language where when you 3/2 you get integer. Try R, the language created/developed by Statisricians for Statisticians. Python doesn't even have a buil-in support for missing data.
I don't know what you mean by built in support for missing data but at language level there is None and in numpy/pandas there is np.NaN
> Any custom Python code, like a function to analyze text in cells.
Sounds like you'll probably be able to hack Excel into running whatever Python code you want using the Azure ML integrations. I guess it'll be Javascript the people currently writing VBA are pushed toward though.
> [The Python developers'] standard answer to "How do I sandbox Python code?" has been "Use a subprocess and the OS provided process sandboxing facilities" for quite some time. [1]
JavaScript, OTOH, is designed to support secure in-process sandboxing. Other languages with such support do exist (e.g. Lua), but JavaScript is by far the most widely known.
[1] https://mail.python.org/pipermail/python-dev/2013-November/1...
Mostly, I think it comes down to Python being designed as a systems language rather than a scripting language. Integrating Python would seem to mean either a weak security model or a special (subset) version of Python. Neither is really going to meet the fat part of the Bell Curve...people who just want to get things done in Excel. Applying a 'browser abstraction' to Excel is probably better than applying an 'OS abstraction'. Anyway, JS has been a part of .NET and VS since JScript. Python, not so much.
Interesting - I hadn't really noticed how pronounced this dichotomy within dynamic languages is. On the one hand there are small languages designed for embedding and sandboxing (e.g. JavaScript, Lua, Tcl) and on the other hand, larger, more general-purpose languages (Perl, Python, Ruby).
I always assumed that a dynamic language could work well in both contexts, but in fact, most lie fundamentally on one side of the divide or the other. Only JavaScript, due to its immense popularity, has really managed (with Node.js) to expand from the first category into the second.
If Python were to be embedded in Excel, it would be expanding from the second category into the first. As you mention, to do this safely it may be necessary to create a special (subset) version of the language. Matz, the creator of Ruby, is trying to take his language in this direction with mruby [1] - a "lightweight implementation of Ruby complying to (part of) the ISO standard".
But, will these subset versions ever be popular? They necessarily leave the majority of the language's ecosystem behind - and knowledge of the full language will not necessarily transfer directly to the subset. Can a subset of an existing general-purpose language, even a widely-known one, compete against other languages that are specifically designed for safe embedding?
More generally, is it possible for a dynamic language to work well on both sides of the divide, or must all (even brand-new) languages choose one side or the other?