By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,341 Members | 1,379 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,341 IT Pros & Developers. It's quick & easy.

Python <=> Excel question

P: n/a

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
Sep 30 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On 9/30/05, Gerry Blais <ge**********@gmail.com> wrote:
Finally, how can I, in Python, make a .txt version of a Word document?


http://www.brunningonline.net/simon/...es/001299.html

--
Cheers,
Simon B,
si***@brunningonline.net,
http://www.brunningonline.net/simon/blog/
Sep 30 '05 #2

P: n/a
> 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?


http://chicago.sourceforge.net/xlhtml/

This has options to output csv files, the list of sheets and many other
things. Just execute this on the .xls file and read the files that it
produces.

Sep 30 '05 #3

P: n/a
Gerry Blais wrote:
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...l/-/1565926218
Oct 4 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.