Open MS Excel Spreadsheet with Python

Allison Bailey allisonb at terralogicgis.com
Mon Jul 14 20:31:47 EDT 2003


Hi Folks,

I'm a brand new Python programmer, so please point me in the right
direction if this is not the best forum for this question....

I would like to open an existing MS Excel spreadsheet and extract
information from specific worksheets and cells.

I'm not really sure how to get started with this process.
I ran the COM Makepy utility from my PythonWin (IDE from ActiveSTate),
using Microsoft Excel 10.0 Object Library, then
import win32com.client
xl = win32com.client.Dispatch("Excel.Application")
wb = xl.Workbooks.Open ("c:\\data\\myspreadsheet.xls")

Then, I get errors when I try the following:
sh = wb.worksheets(1)


I think I'm missing something fairly fundamental, but I've googled all
over the place and can't seem to find anything very introductory about
opening and using data from MS Excel using Python.  Any suggestions,
including places to get more information are welcome.  

Also, do I need to run the makepy utility every time I run my script?
If so, how would I do it from within my Python program, rather than with
the GUI in the IDE?

Thanks for your help,

Allison


~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Allison Bailey
TerraLogic GIS, Inc.
allisonb at terralogicgis.com
425-673-4495
~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 







More information about the Python-list mailing list