
Show HN: Script Excel with Python - karamazov
http://www.ironspread.com
======
smortaz
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](http://www.youtube.com/watch?v=Oi3QKuFugWk&hd=1)

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

~~~
roryokane
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.

------
bmccormack
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!

~~~
karamazov
Glad you like it!

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

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

~~~
DeepDuh
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?

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

------
mwexler
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.

~~~
dbecker
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.

------
yangyang
Nice.

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

~~~
sandGorgon
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...](http://dpinte.wordpress.com/2010/03/12/interactive-python-
graphicsvisualisation-with-excel/)

------
steve8918
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.

~~~
karamazov
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.)

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

~~~
ZoFreX
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?

~~~
jlarocco
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...](http://stackoverflow.com/questions/441758/driving-excel-from-python-
in-windows) (the second answer)

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

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

------
dkhenry
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.

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

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

~~~
karamazov
Yes, they will.

~~~
gsivil
This can be a deal breaker for long long time

------
pneumatics
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.

------
iamdave
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

~~~
karamazov
That's great!

------
pyxll
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.

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

~~~
karamazov
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.

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

~~~
jimberino
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/>

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

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

~~~
fonzie
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.

------
il
Any plans for OS X support?

~~~
karamazov
Not currently.

------
dbecker
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.

------
AlexDanger
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?

------
willyt
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?

------
jaxn
REALLY wish this was available for Mac.

~~~
josteink
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.

~~~
jodoherty
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...](https://developer.apple.com/library/mac/#documentation/applescript/conceptual/applescriptx/concepts/osa.html)

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

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

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

------
bradleyy
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.

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

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

------
asto
Calligra Sheets allows scripting with python, ruby and js!

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

------
canuc
I love you. So much.

------
moolcool
Any plans to support pivot tables?

~~~
karamazov
We will soon!

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

~~~
mdda
FWIW LibreOffice does Python natively.

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

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

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

------
Pyinex
Done two years ago:

Code.google.com/p/pyinex

O.83 alpha version includes the code.

