Lurker News
Folks, Microsoft is officially considering providing Python support in Excel (finally). If you are interested in this, please visit their uservoice page and let them know what you think. Thank you!

https://excel.uservoice.com/forums/304921-excel-for-windows-desktop-application/suggestions/10549005-python-as-an-excel-scripting-language

Comments (268) 74 threads

zoom66286 replies#
Much as i would love for the power of Python in Excel it is important that whatever is done is consistent across the office experience. Some of us old enough to remember the multiple versions of VB-whatever across Excel, Word, Access and that in itself was a blow to productivity.

Yes they should choose Python, and in the process decide if it will be Python with a .Net library (standard and core as seperate libs please!) or IronPython. This in itself is an important first choice.
Then it has to be done in a mechanism that enables the exact same libs and user written python code to work in the same way across all the Office products.
Other languages have been suggested, all good choices with their own merits. Lua is a good chocie for compactness and speed. C# is lingua franca of commercial developers so would suit ISVs but i think too heavy for end user scripting. Nim or even freepascal maybe? Lastly whatabout just using VB.net consistently? VB is a great language for newbs and casual/adhoc programmers .... but it gets ignored because of problems with consistency of implementation by MS.
Last point i would like to make is IMHO the choice needs to be based on: - ability to transpile to javascript so that Excel365 can be scripted from webapps - install-free deployment; should be built into Excel in a way it can be used without any user install for dev or runtime - standard vanilla language, not a variant
Disclaimer: A huge fan and long time user of python here. I also spent largest part of working life in ISV world rather than end user land.

passwordqq2#
Very well thought out answer and agree with the consistency part, don't target popularity, target consistency
tkinz27#
The office 365 support could be implemented using the jupyter kernel protocols rather than transpiling to javascript. That would give them a consistent behavior across desktop and web and even open the door to support more languages in the future if they really wanted to.
sametmax#
The reason Python is a popular choice is because it's a very polyvalent language (not specialized for any task but quite good at a lot of them) BUT the data analysis tookit in the Python ecosystem rocks (numpy, pandas, etc). Lua doesn't have a good data anaylisis story. C# is not made for scripting. VBA is not great outside of Office.

Now given that cPython 3.6 has f-string, and that you probably will use string formatting a lot if you script a MS product, I would implement this version specifically. It's the most recent stable version of the standard implementation anyway.
Actually no, I would not implement anything. I would embed the cPython 3.6 interpreter and stdlib, and just provide a binding to it. This limit the problem of bad / inconsistent implementations that crippled MS products in the past.
Then I would say "we guaranty to provide a 3.6 compatible cPython + stdlib for the next x years" so that people can be confident to write Python stuff. Otherwise, a bad implementation would be worst than no implementation at all.

ptx1 reply#
> VB is a great language for newbs and casual/adhoc programmers

Is it, though? For example, VB puts four different ways of passing arguments right in your face: values by reference, values by value, object references by reference and objects references by value. Python only has the last one and doesn't make you think about it.
And without "Option Explicit" VB does something very unhelpful (also seen in PHP): misspelled variables are created on read and silently converted to the required type, giving you nonsense results. (With "Option Explicit" enabled it gets verbose and tedious instead.)

Scarblac1 reply#
I'd say what Python does is passing object references by value.
ptx#
Right. I listed them in the wrong order and wasn't quick enough with my edit. :)
intrasight#
C# Scripting is a thing now. I've used it on projects. C# makes an excellent scripting language, and in the MSFT space there's probably more of an established practice in that language. I can't imagine why they would use any other language - except perhaps F# or PowerShell.
lazyman75#
Python?!?! "Significant whitespace" is an abomination from deepest layers of hell.
vanderZwan#
> Pyspread expects Python expressions in its grid cells, which makes a spreadsheet specific language obsolete. Each cell returns a Python object that can be accessed from other cells. These objects can represent anything including lists or matrices.

Huh, on the one hand sounds like a such a simple way to deal with it that I can have trouble imagining a more elegant approach.
On the other hand, does it still respect the ways that Excel updates cells? Sicne that kind of requires immutability I think.

throwaway7645#
Also DataNitro
m_mueller#
Haha, I love the little jab at Microsoft's NIH syndrome by suggesting bing search results - seems though that by looking at Python they're slowly getting over that.
odonnellryan3 replies#
So what's the strategy here re: security? I assume it'd be a fairly stripped-down version of Python ... or will you just design the UI to say "you probably shouldn't execute files from people you don't know" etc?
smortaz#
Challenges exist & will have to be looked at for sure. Incidentally, one of the guys on our team just a gave talk on his PEP for "Secure" Python:

https://www.python.org/dev/peps/pep-0551/
There's a YT talk as well.

davb#
I’d rather full fat Python but heavily sandboxed with some form of firewall. “Do you want to allow 2018_Stock_Report_Q1.xlsp to connect to api.erp.corp.mycompany.com?”. Codesigning with my something under my corp CA, manage permissions via Group Policy and let users, on a per-endpoint or per-permission basis, authorise things like filesystem access, network connections, etc.
esmi1 reply#
From a security point of view how is embedding python different from embedding Visual Basic? This is not my area of expertise so I’m genuinely curious.
Groxx2 replies#
Potentially different. .NET allows signed binaries / libs / a fully signed execution context, Python has nothing equivalent AFAIK.

Continue this thread — 2 replies

Nullabillity1 reply#
> @ msft

Well, I guess that explains why you care about Office in 2017.

canadianwriter1 reply#
That and the fact that the vast majority of companies use Office...
cm21874 replies#
Which is also why it is surprising that Microsoft has spent so little time on office in 20 years. Outside of changing the colors regularly, there has been very few new significant functionalities between Office 2003 and Office 2016. And opening the VBA IDE is a nasty reminder.

I'd argue large companies are still running Windows because of Office. The cost of retraining people, redesigning all of these user processes and converting all those documents would be massive. Whereas most new corporate applications in the last 5 years have been mostly web based.
So I am surprised Microsoft under-invest in what is they main strategic lock-in in the juicy enterprise market.

Continue this thread — 4 replies

bdowling2 replies#
So, would this imply numpy and scipy support in Python for Excel? How about support for Excel worksheets within Jupyter notebooks?
smortaz2 replies#
That's for the Excel team to decide. My personal hope is that they'll offer as a base:

* Python 3
* Numpy, SciPy, Pandas, Matplotlib, Altair, ...
* Pythonic bindings for Excel APIs (sheets, etc etc)
* VSCode's Python Editor + Debugger built in
* Some sort of conda based env/pkg mgmt
* Right-click, "Open in Jupyter" (data/code)
*

vvanders3 replies#
Yeah, matplotlib, scipy and numpy are kinda no-brainers there.

Continue this thread — 3 replies

auxym7 replies#
Transparent access to Excel tables as Pandas Dataframes would be so, so very awesome.

I mean, MS implemented these really nice Tables in excel, but then left us no way to easily query them with something like SQL.

Continue this thread — 7 replies

ateesdalejr#
No, watch them pump out some horribly supported python library .
askvictor2 replies#
Interestingly, the survey doesn't seem to consider education as a use-case of this - has your team considered that aspect? Spreadsheets are the most common way that school students are introduced to programming, and the only 'programming' that a lot of teachers (and others) do. There are heaps of reasons for this, but any even moderate programming (beyond very simple operations) in a spreadsheet sucks. Something like this (if it's easy out of the box) could revolutionise programming education (and data education for that matter).

Are there plans to get this working with the Excel web-app, or just the desktop version? I'm just having a daydream about Excel, Juypter notebooks, and OneNote Class notebooks...

smortaz#
That's a very good point! I hope you provided that input :).

Our team provides a free service for anyone to run Jupyter Notebooks on Azure. It's currently a big hit with the Edu crowd. We're seeing lots & lots of universities upload & teach courses on it. eg:
http://notebooks.azure.com/richie
There's also an Intro to Python notebook on the front page.
Hopefully the Excel team will consider Jupyter integration, esp for the web-app version! You're right that it's a killer combo. Check out xlwing's video on using Excel+Jupyter - it's brilliant.

rmbeard#
I think we will see and are already seeing a move away from using spreadsheets in Education, there are simply much better solutions out there now. Jupyter notebooks being one which allow reading and writing to Excel files. The interface of these is far superior for educational purposes than a spreadsheet. I've already dropped Excel for this reason.
jimnotgym1 reply#
Imagine all of those simple tasks that you could do in seconds with a python script. Export to csv in UTF-8 with double quoted fields. Loop through cells

  for row in rows:
     do some cool stuff
Pull data from a REST API using requests rather than some VBA hack. I'm getting over excited already. Edit data for your ERP and then post it back to the API and update the db... This is exactly what finance/data people want. Write custom functions (with numpy maths!)! No more nested If's. This will keep Excel as the premium spreadsheet app. I love it
discreditable#
I already find myself reaching for Google Sheets quite frequently just to do this. I'd love to be able to use Python instead of JavaScript.

Load more comments