Open MS Excel Spreadsheet with Python

William Peterson wpeterson1 at socal.rr.com
Tue Jul 15 16:48:01 EDT 2003


"Allison Bailey" <allisonb at terralogicgis.com> wrote in message news:<mailman.1058229111.12248.python-list at python.org>...
> 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")
> 
At this point, I don't believe you're doing Python any more, but
Visual Basic for Applications

> Then, I get errors when I try the following:
> sh = wb.worksheets(1)
>
Is worksheets the proper term or should it be Sheets? Probably depends
on the version of Excel/VBA

Im looking at "Python Programming on Win32", an Oreilly book. If you
really must work with Excel or Word you should get it.

Bill




More information about the Python-list mailing list