Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: Script Excel with Python (ironspread.com)
280 points by karamazov on June 8, 2012 | hide | past | favorite | 61 comments



This is great guys! We cooked up a similar thing called Pyvot (pivot). It's OSS/Apache - feel free to take/contribute. Cheers, smortaz@microsoft.

Video: http://www.youtube.com/watch?v=Oi3QKuFugWk&hd=1

edit - link to project: http://pytools.codeplex.com


More specific link to Pyvot project: http://pytools.codeplex.com/wikipage?title=Pyvot.

My understanding of the difference between the links: Pytools in general lets you run Python programs in Visual Studio. Pyvot is a part of Pytools that lets any Python code on Windows (including code run in Visual Studio) connect to Excel.


I still have a soft spot for VBA, especially in Excel. I wrote a supply-chain management application in Excel+VBA that's still in production today. As comfortable as I am with VBA, I wouldn't mind in the least ditching it for Python, which makes writing routine methods trivial. Great work!


Glad you like it!

We're also backwards compatible - you can keep running old VBA code, and write new scripts in Python.


So many offices have lots of functionality written as VBA, you've made a lot of people very happy by giving us Python to play with!


Wow, backwards compatible?! That's awesome. That must have taken some serious COM magic.


Could you elaborate? Why shouldn't two script engines run alongside each other, as long as it's not at the same time on the same data?


I was under the impression that it meant you can call into VBA from Python and vice versa.


That's very clever. However, the ultimate integration of spreadsheet and Python has got to be ResolverOne (http://www.resolversystems.com/products/resolver-one/) It's a really amazing experience.


I don't doubt that ResolverOne is a great experience... but so many businesses are wedded to Excel (and VBA).

I expect IronSpread will see much more use than ResolverOne because it will integrate into these offices more easily.


Nice.

Also see PyXLL (http://pyxll.com/), which lets you write Excel plugins in Python (CPython).


Thanks for this - it indeed looks much more powerful (being able to interact with Excel using Python as well as making python functions available to Excel).

Just saw this example - http://dpinte.wordpress.com/2010/03/12/interactive-python-gr...


What is the licensing for this? I couldn't tell whether this was free, if I had to pay, if it was open source, GPL, etc.


It's a free beta. We'll be charging for it down the line, but you can use this however you like for now. (It's not open source, though.)


Why would I use this when I can already connect to Excel using COM for free?


That's the most perfectly ambiguous sentence I've ever seen on here, I actually can't tell if you're being sarcastic or not. Are you?


It was a real question.

COM isn't hot new technology, but it works, costs $0 above and beyond Excel, and can access as much (or more) of Excel.

The reason I ask is that after a quick look, the IronSpread examples don't look too much different than accessing Excel via plain old COM. [1]

And there's even a chapter in a book [2] for accessing Excel from Python through COM.

And example code [3] for wrapping Excel COM in a Python class.

I guess put another way, my question would be what does IronSpread offer above and beyond the regular access from COM?

[1] http://stackoverflow.com/questions/441758/driving-excel-from... (the second answer)

[2] http://my.safaribooksonline.com/1565926218/ch09-84996

[3] http://dzone.com/snippets/script-excel-python


This is for extending Excel. I'm not sure how easy it is with COM (I'm sure it's possible) but you are paying them to make it easy for you.


When I use COM, it's usually free.


Why would I use this when I can already connect to Excel using PyWin32+COM and be able to interact with Excel in Python for free?

FTFY


> We'll be charging for it down the line

Implement billing. Now. No excuses.


The big question I have is why would I use this instead of a real database. If i am not mistaken excel can hook up to ODBC sources and then I can just script things as I normally would using the database drivers.


Hoho, you ever sniffed the real world out there? Hell of a lot more excel junkies than programmers.


If you want to script something quickly, Python is better; you also have access to all of Python's libraries (numpy/pylab, for example).

It depends on what you're doing, though.


Impressive. Would people I share a spreadsheet with need the plugin?


Yes, they will.


This can be a deal breaker for long long time


This isn't necessary, you can have access to the full Excel COM API, with tab-completion, backwards-compatibility etc, for free with iPython and the makepy.py script.

http://stackoverflow.com/a/445961

Though I admit scripting Excel from Python should be easier to setup than it is.


This is awesome! I plan to use this 100%. Sent it to a few other excel power users in my org, thank you for this


That's great!


If you want to call Python functions from Excel in the form of user defined functions, macros or menu functions (including macros bound to UI widgets and application events) you should take a look at PyXLL (www.pyxll.com).

This has been around for a couple of years now and actively maintained and supported, and is in use by many organisations already. It supports all versions of Excel from 2000 onwards, with some features only available in later versions (eg asynchronous functions are only in Excel 2010).

It uses cPython so all the standard libraries are usable.

Calling back into Excel is quite straightforward using win32com, and there are examples on the website that show how to do that.

With PyXLL you can write plain Python code that you can use outside Excel as well - so it's quite easy to write a library of functions that can be called from normal Python scripts as well as expose them to Excel at the same time.

I'm not sure what this project adds over what's already available but I'd be very interested to hear what other people's opinons are.


This seems really cool, but I'm admittedly not familiar with this area. How does this compare or supplement to Excel VBScript?


Our goal is to replace VBScript. We'll have the same basic functionality, but using Python instead of VB, and with access to all of Python's libraries.

It's backwards compatible too - you can run VBA scripts and Python scripts at the same time.


That's funny, I just used xlrd and xlrt and had to convert about 100 files to 97-2003 workbooks


XLRD and XLRT look awesome - esp. for us *nix minded folks who prefer to interact with xls files from a shell, http://www.python-excel.org/


This seems pretty great. Any plans for compatibility with Excel 2003 and 2007?


We'll be compatible with 2007 in a day or two. We're not currently planning on supporting 2003, but this might change.


Awesome. You may already know, but a huge proportion of the large finance firms are still stuck with 2003 and from speaking to a few people, they don't seem super ready to change. Given you are planning on selling it, these guys would probably be decent customers.


Any plans for OS X support?


Not currently.


This solves a real business problem for a lot of people. I'm doubly impressed that it was done by a recent grad and someone still in school.

You guys have a bright future in front of you.


This is great. I have to work with some very complex excel/VBA apps and this will be a breath of fresh air.

Is there anything out there that allows using C# to script/control excel?


Honest question; I havent tried to script xl or word for years. What is this doing that I couldn't do with IronPython or IronRuby?


REALLY wish this was available for Mac.


Ask Apple for something equivalent of Windows COM+ and convince them they have a good reason for doing so once they stop laughing, and then you might have it.


I realize this isn't the same thing, but a lot of Mac apps are scriptable through Apple's Open Scripting Architecture [1], so it's more than possible to use Python [2] or Ruby [3] or any other language with an OSA bridge to access and reuse application functionality or to automate tasks. According to Wikipedia, Microsoft Office 2008 supports OSA, so it's worth investigating with Microsoft Office 2011. You can use the ASDictionary app from the appscript page [4] to see what scriptable functionality, if any, various Microsoft Office for Mac applications support.

References:

[1] https://developer.apple.com/library/mac/#documentation/apple...

[2] http://appscript.sourceforge.net/py-appscript/index.html

[3] http://rubyosa.rubyforge.org/

[4] http://appscript.sourceforge.net/tools.html#asdictionary


Yep, me too!

Would it be possible to use this as a standalone (command line for instance) and not a plugin?


Sorry, it's not possible now. Microsoft's technology is not there yet at MacOS.


From a conversation with them, they are intending to charge around $2000/seat/month. This takes it out of the realm of possibility for me, but http://excel-dna.net/ looks like it will fit the bill with a little elbow grease.


This is very interesting! Wrapping the entire Excel object model in Python must be a huge work.


Great work. I am a long time finance geek - this will make life decidedly easier.


Calligra Sheets allows scripting with python, ruby and js!

http://en.wikipedia.org/wiki/Calligra_Sheets


I love you. So much.


Any plans to support pivot tables?


We will soon!


niiiice! :) python is definitely better than vba, didn't think of this use for it!


FWIW LibreOffice does Python natively.


Is this an open source project, or are you planning to sell it?


It's free for now, but we plan to sell it eventually.


If you don't mind me asking, what did you use to create the plugin? Just simply VS or did you use a framework?


Done two years ago:

Code.google.com/p/pyinex

O.83 alpha version includes the code.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: