Python <=> Excel question

G

Gerry Blais

Newbie questions:

Suppose abc.xls has sheets a, b, c.

How can I find, in Python, the sheet names?

Given a sheet name, how can I export the sheet as a csv file?

Finally, how can I, in Python, make a .txt version of a Word document?

Thanks,

Gerry
 
M

Magnus Lycka

Gerry said:
Newbie questions:

Suppose abc.xls has sheets a, b, c.

How can I find, in Python, the sheet names?

Given a sheet name, how can I export the sheet as a csv file?

Finally, how can I, in Python, make a .txt version of a Word document?

I think Google will help you to find plenty of solutions to these
things. It's probably better to try something out and come here if
you're really stuck. You might want to start with this...
http://www.markcarter.me.uk/computing/python/excel.html

In general, it's typically helpful to use the VBA editor in Excel
to discover what the object model looks like, what methods there are
and what parameters they take etc. Then you can use this from Python
via win32com.client instead. You need the win32all extensions for
Python (or something like ctypes, but I never used that). ActivePython
contains win32all by default, but it's simple to install win32all for
a vanilla Python installation. It's reachable through the normal
Python download page (or via Google of course).

I'm sure some experimentation based on these hints can solve your
problem. It takes some time to understand the object model, and
how it maps to the Python interface, but it's not rocket science.

This book is really helpful for understanding how to use Python with
e.g. Word and Excel:
http://www.amazon.com/exec/obidos/tg/detail/-/1565926218
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,264
Messages
2,571,323
Members
48,008
Latest member
KieraMcGuf

Latest Threads

Top