back to article Microsoft teases Python scripting in Excel

Microsoft has added support for running Python code from within Excel, bringing the world's most popular programming language, by some measures, to the world's most popular spreadsheet. Sorry, Visual Basic. "Today, we are excited to introduce the public preview of Python in Excel – making it possible to integrate Python and …

  1. sarusa Silver badge

    Nice in concept but...

    I love the idea of being able to use python instead of their terrible BASIC (VBA), but now /every single/ python calculation in the spreadsheet gets sent to TEH CLAUDE and back?

    So now even simple spreadsheets are network chatterboxes and don't work at all if you don't have network access, like on a plane or way the eff out in the field, or maybe your ISP is just having yet another outage.

    The obvious reasoning for this is so they can have a peek at your data and even more so they can charge you fat subscription fees for it. They're trying to make Office entirely cloud hosted anyhow (so you can't even run it locally) so this would be one more step towards that.

    1. bazza Silver badge

      Re: Nice in concept but...

      I can see why they'd not want to let Python loose inside Excel, on customers' PCs, able to cause havoc. But yes, shoving it up in t'Cloud is going to be annoying.

      Or, could be useful: "Wiggins!" bellows the boss, "Where's your end of year sales figures? They'd better be good mind you, or your for it <insert rambling stream of typical managerial threats involving paperclips, the stationery cupboard, the worst taxi company in town and an ants nest>". Wiggins: "Well, thanks to our new version of Excel, all the numbers are stuck in the Cloud, sir, but I can assure you that they were most excellent, especially once I'd manipulated the dependencies sir (books one way ticket to, well, anywhere)".

      1. Richard 12 Silver badge

        Re: Nice in concept but...

        Sandboxing the runtime is a "solved problem" (we do it in some of our products), so it's clearly entirely about creating a dependency on Azure.

        And charging for it. Opening this spreadsheet will cost you...

        1. Anonymous Coward
          Anonymous Coward

          Re: Nice in concept but...

          "Opening this spreadsheet tomb will cost you..."

          Python, Anaconda, Microsoft...

          Snakes... why did it have to be snakes.

    2. vtcodger Silver badge

      Re: Nice in concept but...

      Now that you mention it, yes, Rube Goldberg -- master of wildly complex "solutions" to simple problems -- would no doubt find much to admire in the computation of spreadsheet cell using a distant computer and an elaborate communication network.

      BTW, I'm pretty sure that Open Office has had Python scripting in Calc for a LONG time. My vague impression is that it works fine (and without the cloud) but isn't very useful for most people most of the time.

      1. Paul Crawford Silver badge

        Re: Nice in concept but...

        It is only a "nice concept" until you ponder just how horrible a complex spread sheet is to audit/debug in practice.

        You know, the one Jimmy boy in accounts did years ago and then left with no documentation?

        There is clearly a place for data analytics, etc, but spreadsheets are already way over-used and abused for this. Sadly for most managers/accountants this is the only tool they know about, so it gets used as a computing hammer. But such business "dependency" is EXACTLY what MS wants to encourage to get people locked in to endless subscription payments.

      2. George Orwell

        Re: Nice in concept but...

        Why would anyone use Microsoft Excel? OpenOffice is better and it's free:

        You can assign custom scripts (macros) to menu items, icons, dialog controls, and events in OpenOffice.

        OpenOffice internally supports the following scripting languages:

        1. OpenOffice Basic

        2. JavaScript

        3. BeanShell

        4. Python

        1. jgard

          Re: Nice in concept but...

          Hey, I love open source, and yes, VBA is bloody awful, but please tell me why Open Office is better than Excel. You've listed the scripting languages, which are definitely more varied in Open Office, but remain irrelevant in 99% of use cases. So what is so much better in OO compared to MS Excel? I've recently had to start using OO at work and on any objective measure, it is NOT better software than MS Office, it just isn't.

          I hate Windows and refuse to use it - there are far better alternatives for an OS. MacOS, Ubuntu, and Mint all fit the bill. There are much better web servers than IIS, better hypervisors than Hyper-V, and better web frameworks than But for office apps, I don't see it fella. What exactly makes Open Office better than MS Office?

          1. Ken Moorhouse Silver badge

            Re: What exactly makes Open Office better than MS Office?

            Less susceptible to malware would be my immediate thought.

            If something requires something more sophisticated than OpenOffice or LibreOffice then the wrong tool is being used for the job. This is particularly true for Excel where people use it for 'production' purposes all the time. I write database applications to combat this which, if a spreadsheet needs to be surfaced, I write that xlsx out as a plain file with no embedded macro capability, or csv which is 'plain' by definition. Maybe an MD5 hash or similar mechanism would be needed if tampering were considered a problem.

            'Production' in many instances I've encountered in industry is for the purpose of sharing or exchanging data with external companies. It seems that companies that specify xlsx or csv formats possibly feel that a more appropriately 'robust' sharing method is just too complex for their partners to get their head round. I appreciate EDI is overkill for many applications, but there are alternatives.

      3. katrinab Silver badge

        Re: Nice in concept but...

        Excel recently introduced, the world’s least popular programming language, JavaScript, and that runs locally.

        Maybe you could integrate Python stuff into that using Brython or Pyodide?

        As for whether you should, we’ll we are talking about JavaScript, and clearly nobody ever stopped to ask that question, because lots of people use it.

        1. Anonymous Coward
          Anonymous Coward

          Re: Nice in concept but...

          that would due to office apps now being fancy browsers to the cloud

    3. NeilPost Silver badge

      Re: Nice in concept but...

      Smells like M365 only.

      1. Nevermind

        Re: Nice in concept but...

        Think that's why the pic is a grass snake...python-in-excel concept is M365+grass snake in reality

    4. Anonymous Coward
      Anonymous Coward

      Re: Nice in concept but...

      most office apps now actually seem to be a fancy version of a browser, surprise it's already all in the fucking cloud

  2. Jou (Mxyzptlk) Silver badge

    I'd rather prefer powershell in Excel

    Just my opinion though. Would finally fix the powershell <-> excel bridge much better. And I could stick to use "english" and programming language. Anyone who has ever seen those horrible translations of the excel language (if then sum etc formula words) translated into their native language, here German, knows what I talk about. I cannot handle the translated programming language, especially since I started with MS-basic 2.0 and 3.5 on 6502 / 7501 CPU, and no easy way to turn it to "use english function names dammit" there. Something libreoffice can.

    1. Lil Endian Silver badge

      Something libreoffice can.

      Something else LO can do: Python macros. No fekkin cloud required :)

      1. alain williams Silver badge

        Re: Something libreoffice can.

        Libreoffice does not need a cloud to do this as there is no intention/plan to charge you lots of $$ to do this.

      2. david 12 Silver badge

        Re: Something libreoffice can.

        What LIbreOffice can't do is VBA. If OO had ever got an effective VBA implementation, there wouldn't have been any interest in python macros.

        FWIW, two problems LO has with VBA, that python solves: LO can only do "declare" on Windows and Mac, and, even on those platforms, it doesn't do stack protection (required both for stability and to prevent clusters of CVA's). That means you can't do external calculations and interfaces on linux -- one of the required use cases both for VBA and python.

        One thing missing from LO, that Excel will probably have: proper integration into the Excel environment. The LO implementation of python is effective on supported platforms (how much effort it takes to get it to work on linux depends on which distribution you have), but the integration into the LO programming environment is half-assed. I find myself saving the spreadsheet, unzipping it, opening and editing the python files in vi or notepad++, then saving, zipping, and re-opening in LO.

        1. CowHorseFrog

          Re: Something libreoffice can.

          Python bindings to a spreadsheet is not the same as embedding python as part of a formula expression.

        2. Charlie Clark Silver badge

          Re: Something libreoffice can.

          VBA may have been well-intentioned but it's probably one of the worst decisions Microsoft made with Office. Too difficult for the Office-scipt kiddies and too much of a toy for the programmers. The limitations are one of these reasons why tools like Pandas were developed. Since then Excel has become less and less of a runtime and more and more merely a reporting format.

        3. nijam Silver badge

          Re: Something libreoffice can.

          > What LIbreOffice can't do is VBA.

          Delighted to hear that.

          Never tried VBA in LO, of course, why would I? VBA looks like one of those languages developed by someone who'd heard of programming, but never tried it.

          1. Charlie Clark Silver badge

            Re: Something libreoffice can.

            Actually, it was developed by language experts for novices and ended up being hated by both. I wrote my first ever code in BASIC and have always liked it as a language for novices. When Microsoft went all .NET it decided that VisualBasic had to as well and suddenly forced a load of new constructs and syntax onto people that didn't help them one bit. After that VB and VBA fell quickly in popularity because, if you're going to use static typing, etc. you might as well use C#, Java or even C++. But the majority of users where overwhelmed and looked for alternatives; it's no coincidence that Pandas and Jupyter Notebooks were developed with the Excel community in mind.

        4. Zippy´s Sausage Factory

          Re: Something libreoffice can.

          What LIbreOffice can't do is VBA.

          As someone who has made a good living from VBA for several years, I can confidently assert that Excel isn't that great at it, either.

          1. Lil Endian Silver badge


            Thanks for that! :D Here -->

      3. Anonymous Coward
        Anonymous Coward

        Re: Something libreoffice can.

        aaargh didn't realise LO is filled with python shit

  3. Ken Moorhouse Silver badge

    Snakes on a dataframe


    Or worms?

  4. bazza Silver badge


    Oh dear holy $DEITY, no!!!!!

    1. bazza Silver badge

      Re: Aaaaaaarrrrrrrrgggggghhhhhhh!

      Ok, I've read that they've gone and containerised it a long, long way away in the cloud. But, I honestly don't get the point. If you're going to program in Python, just use Python. Surely, the Excelness of the experience would simply be an embuggerance for the Pythonista, and the Pythonness of it won't help anyone just wanting to use a few simple formula... And the portability of the end result is...... nil.

      1. bombastic bob Silver badge

        Re: Aaaaaaarrrrrrrrgggggghhhhhhh!

        Or it is step 1 of 'Embrace, Extend, Extinguish'

        Wait until you see "Visual P++"...

        1. Lil Endian Silver badge

          Re: Aaaaaaarrrrrrrrgggggghhhhhhh!

          Wait until you see "Visual P++"

          If I weren't so jaded, that thought would have me twitching. If I were fickle, the actuality would have me heading to Beachy Head.

        2. bazza Silver badge

          Re: Aaaaaaarrrrrrrrgggggghhhhhhh!

          >Wait until you see "Visual P++"...

          I refer you to Iron Python...

        3. Anonymous Coward
          Anonymous Coward

          Re: Aaaaaaarrrrrrrrgggggghhhhhhh!

          about time python got extinguished, shit hyped language that needs to die in a fire

          1. Sceptic Tank Silver badge

            Re: Aaaaaaarrrrrrrrgggggghhhhhhh!

            Hahaha. I need to create about 50 additional Register accounts so that I can upvote you more.

          2. Plest Silver badge

            Re: Aaaaaaarrrrrrrrgggggghhhhhhh!

            Python and business users are like the difference between a professional builder and a home DIY hobbyist. To do something well you need to be doing it year after year, business users slap some scripted lines together they copied off Stacktrace and then go ahead and make multi-million pound decisions based on their 2 weeks of coding prowess! Coding, like building, might look eaiser to the hobbyist but what you don't see are years and years of experience to know when something is done properly, coders will unit test, QA code, double check, they don't just slap Stacktrace snippets together and pray it works ( well most don't! ).

            I'm not a fan of Python, its slap-dash formatting style just makes me feel unwell, I don't wish anyone to stop using it as it's getting kids and non-coders to enjoy coding, just when you need serious coding ( or a wall built ) please hire a professional.

      2. david 12 Silver badge

        Re: Aaaaaaarrrrrrrrgggggghhhhhhh!

        But, I honestly don't get the point

        Well, I can answer that. Because, for some problems, the spread sheet is the preferred/appropriate user interface.

        I did my "Mathlab" problems in Fortran. My Dad did his 'accounting' in BASIC. But that was because Mathlab and Lotus 123 weren't options at the time. I totally understand programmers wanting to program in /whatever language/, but programming a spreadsheet user interface in python just because you don't want a LO dependency is a sub-optimal solution

      3. Charlie Clark Silver badge

        Re: Aaaaaaarrrrrrrrgggggghhhhhhh!

        I can give an example from our developers this morning: sets of poorly curated, incomplete and non-normalised customer locations from business to be imported into our database. Developer converts to CSV, loads in Pandas, cleans up, normalises and imports. Leaving aside that the conversion to CSV wasn't necessary and is IMO never advisable (lose types and character set becomes an issue), this is a task that can largely be performed by business in the future. Yes, a heap load of provisos but we will be able to write the functions that they run directly in Excel.

  5. bombastic bob Silver badge

    cloudy 'security'

    "the cloud habitat for Anaconda's Python will presumably be more secure than having Excel users downloading libraries on their own. Having anticipated concerns about enabling yet another attack vector in Excel, Microsoft has preemptively declared that its snake has been tamed.'

    HA HA HA HA (oh wait, they're serious; let me laugh even HARDER!)

    What part of THIS is 'more secure' ?

    * Data stored in the cloud where governments and evil hackers can view it

    * relying on "their server" performance including the pipeline to/from it

    * DDoS, downtimes, network problems, MItM and DNS cracks, etc. NEVER HAPPEN, right?

    More exist but another post near the top hit on the best ones

  6. thames

    Pandas and Anaconda

    Given the repeated references to Pandas and Anaconda, I suspect that what this is really about is using Excel as a front end to Pandas (a major Python data analysis library).

    Pandas is so important and so widely used in certain fields of application (data science, machine learning) that people are learning Python just in order to be able to use it. People who had previously used Excel for certain small to medium size tasks are dropping it in favour of Pandas when Excel starts to run out of steam on really big tasks. The data and calculations will reside in Pandas, while Excel is used for data entry and reporting.

    Given this, the way that Microsoft can respond is to build Pandas access into Excel. In order to do this they need to add Python scripting into Excel. They then run the calculations in the cloud because the really lucrative (for Microsoft) applications will be ones which are too big to run on a PC.

    I suspect they will eventually offer tiered accounts, with prices escalating with cloud instance size.

    1. Mark 65

      Re: Pandas and Anaconda

      If you're just using Python for pandas I'd be using R's data.table library as it is much easier to use and has a more SQL-like natural language filtering aspect to it whereas indexing in Pandas is somewhat of a comparative cluster-f*ck.

      1. find users who cut cat tail

        Re: Pandas and Anaconda

        R is nice. It is even more readable then Perl!

        But seriously, if you learn Python for pandas, with some luck you might end up learning Python, a generally useful programming language. With R you end up with a lanague which is very efficient at specific things and frustrating when you need also to do some ‘normal’ programming.

        1. Someone Else Silver badge

          Re: Pandas and Anaconda

          R is nice. It is even more readable then Perl!

          Rather low bar there. The only language I have come across less readable than Perl is APL.

          Well, there is SNOBOL2, and RPG, but neither one of them really qualify as "languages" per se...

          1. Strahd Ivarius Silver badge

            Re: Pandas and Anaconda

            I want Brainfuck!

      2. Charlie Clark Silver badge

        Re: Pandas and Anaconda

        While Pandas is an example of feature creep it has helped millions of people to do things they struggled to do, usually in Excel, before. R may have its fans but I know a number of people who've dropped it for Python because of the other stuff they need to do.

        Pandas itself is getting a rewrite but alternatively there is Polars (written in Rust) which has the same idea but without the cruft.

        1. katrinab Silver badge

          Re: Pandas and Anaconda

          And, at least for some tasks, there is Numpy. That’s what I generally use. I find it to be about 30-100x faster than Pandas for the things I do.

          1. Charlie Clark Silver badge

            Re: Pandas and Anaconda

            Pandas uses Numpy for all its data structures but it is terrible at indexing, which is why it's usually better to create new dataframes. Polars (written in Rust) uses Apache Arrow for dataframes, which means no memcpy(). The API looks a lot cleaner than Pandas all singing and dancing one.

        2. seansaysthis

          Re: Pandas and Anaconda

          Apparently all the cool kids are using Polar or Arrow. But it's great we have all of these cool tools.

      3. Anonymous Coward
        Anonymous Coward

        Re: Pandas and Anaconda

        python is A clusterfuck and needs to die in a fire

    2. Handlebars

      Re: Pandas and Anaconda

      If you're going to learn python to do the analysis you might as well use it for the reporting too.

      As for using Excel for the data entry, apart from it being hard to control inputs, if people are entering data by hand you probably don't have enough volume to really need to go beyond Excel in the first place

      1. katrinab Silver badge

        Re: Pandas and Anaconda

        Kind-of, but Python isn’t that good for front-end programming.

        You can use Jypyter, and I frequently do. Otherwise it is going to be a web application with a JavaScript front-end which is not really beginner-friendly as far as programming goes.

    3. seansaysthis

      Re: Pandas and Anaconda

      Yep, excel wasn't designed to work with large data sets. Don't get me wrong it's still a great tool.

      I had some python experience from some sysadmin tasks. I was given a spreadsheet sheet with approx 500k records and needed to identify the duplicate records based on different data fields. Even the 64bit version of excel would lock up.

      A day later a 14 line script with pandas identified the duplicate records and outputed the common records to another file so we could investigate and reconcile the records. Took it about 5 mins to spit out the output.

  7. karlkarl Silver badge

    Apparently porting VBA (actually, the VB6 VM) to the web via Emscripten was deemed too difficult for Microsoft, so Python is the approach taken so that they can move all their consumers to the cloud builds.

  8. t245t

    How to integrate Python and Excel with xlwings

    How to Supercharge Excel With Python

  9. Anonymous Coward
    Anonymous Coward

    Evangelism Is War......


    ......but who is the enemy chosen for this evangelism?

  10. CowHorseFrog

    Given Python can do anything like write files or network calls its interesting the blog and article mention nothing about sandboxing or is this a free for all like ActiveX ?

    1. Ken Hagan Gold badge

      "In a post on data security and Python in Excel, Redmond lists the following plus points.

      Excel's Python code runs on hypervisor isolated containers built on Azure Container Instances.

      The container has Python and a curated set of secured libraries provided by Anaconda.

      The Python code does not have access to the user's computer, devices, account, the network, any user token, or workbook properties, including formulas, charts, PivotTables, macros, and Visual Basic code."

      1. Plest Silver badge

        "Excel's Python code runs on hypervisor isolated containers built on Azure Container Instances."

        Ah, so they can charge you even more money for using underlying infrastructure kit! Gotcha!

  11. Charlie Clark Silver badge

    Code will be stored in the files

    Someone from Microsoft has already been in touch to let me know that the Python code will be serialised as text in the files. This will make it possible to share whatever is required for the report. Need to decide whether I'll expose this or just preserve it in the Excel archive.

  12. werdsmith Silver badge

    My "pocket" calculators from both Casio and TI have Python capability and a sort of spreadsheet function.

    Seems to be taking over as the de facto scripting language usurping the ECMA/TYPE JavaScript variants.

  13. Anonymous Coward
    Anonymous Coward

    Microsoft has added support for running Python code from within Excel

    About time. VBA sucks.

    They've added Power Automate in now though, which has a range of connectors though.

  14. Reaps


    Bringing 2 of the worst of the worst together in a shitty pile of crap, that M$ in a nutshell

  15. IceC0ld

    Obligatory XKCD

    T - otal

    I - mmersion

    T - otally

    S - implifies

    U - ploaded

    P - arameters

    1. Plest Silver badge

      Re: Obligatory XKCD

      The second XKCD is the reason I cannot take Python seriously for anything I needed to write, instead became an azure coloured Gopher!

  16. Anonymous Coward
    Anonymous Coward

    Macros in office - what an incoherent bloody mess

    Recently there was literally nothing else I could do get a macro I'd written on another machine working in Excel on a personal laptop. I went through various steps of trying to get Trust Centre to trust everything, trust the place I'd originally written the macro and so on, all with no joy. Absolutely useless. Add to that Microsoft now has three Macro languages for Office - VBA, Office Script* and now Python**. Given the opportunity, I'd gladly move to Libre (or even Google).

    * Enterprise licence only.

    ** With whatever caveats.

  17. Steve Channell

    another demo?

    The Microsoft of old (when Bill Gates was still CEO), the Office team took the bold decision of scandalizing on one language and runtime that would automate other applications (if you happened to think that was a good idea). We decry VBA now, but it has been frozen for two decades.

    The truth is the Office team are out of idea, and churning out new demos to make people think they are getting something for new for their subscription fee. Delivering Office via a browser seems like an incredible feat, but functionally similar to running Multiplan & Word on Xenix in 1981. Providing hosted access to Anaconda Python streamed to client/browser looks incredible, but functionally similar to using MS Multiplan with SAS or SPSS in the early 1980’s.

    A bold Microsoft wouldn’t just add another demo product, but integrate Python fully into Windows & Office, or better still – do something better

  18. CowHorseFrog

    Strange they picked python, surely using a dot net language would actually have. made more sense ?

  19. Strahd Ivarius Silver badge

    A new language will be implemented in Word

    SPL of course

  20. Binraider Silver badge

    Oh, for god's sake. I've only just persuaded the powers that be to purge the unsupported / unmaintained / uncommented and unresilient python scripts that permeated through a bunch of business processes - only for the business to make the team that did them redundant then wonder why crap was breaking.

    Another tool on the stack is not what we need to get things in order. Replacing VB with Python one supposes could be be an improvement.

    But too many people are in the business of agile development and shortcuts rather than favour measured development with clear objectives and resilient design.

    Blech. I'll be glad to get out of business sooner rather than have to deal with such shiat.

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon

Other stories you might like