Is there a way to push data into Microsoft Excel & Word from Python ?

Caleb Hattingh caleb.hattingh at gmail.com
Sat Dec 16 16:19:41 EST 2006


The Night Blogger wrote:
> Is there a way to push data to Microsoft Excel & Word from a Python
> Application

On Windows, it's easy after you install the win32 extensions.  For
example, for
python:

import win32com.client
xl = win32com.client.Dispatch('Excel.Application')

after which you can operate on "xl" (almost) as if you were coding in
VBA.   I have driven Excel from python a /lot/, and it works well.
Paul Boddie has written a great tutorial---which includes some Outlook
examples, btw---over here:

http://thor.prohosting.com/~pboddie/Python/COM.html

> Is this a cross platform feature ? I'll need to push data on MS Windows &
> Mac OS X ....

I have zero OSX experience, but 30s of googling brings up this:

http://appscript.sourceforge.net/

Kevin Walzer mentions on this mailing list entry:

http://mail.python.org/pipermail/python-list/2006-August/400255.html

that Excel provides reasonably good support for applescript, but again,
I have no idea whether these things work; I'm just doing your googling
for you.

Assuming applescript works, you may want to write a thin wrapper over
the combination of the win32 COM interface and the applescript
interface that at least lets your business logic sit in one place.  The
wrapper can use the right API depending on the platform it finds itself
on at runtime.

Regards
Caleb




More information about the Python-list mailing list