wxPython Not Ready for Commercial Use

Fritz Bosch uthand at hotmail.com
Fri Sep 17 08:28:21 CEST 2004


Paul McNett <p at ulmcnett.com> wrote:
> Andrew Durdin writes:
> 
> > I was recently involved in a project which required producing
> > excel files programmatically (this was from VB *spew*). I
> > started off using COM, but it turned out to be unreasonably
> > slow for filling in all the cells that we needed to do; so
> > instead we output an XML spreadsheet. It was much faster, and
> > simpler in the end.
> 
> I used COM to do an Excel spreadsheet once. It was pretty 
> complex and took an outrageous amount of processing time. And 
> then the client updated Excel and had to call me in because 
> something in the COM interface changed.
> 
> I wonder if your XML method has a better chance of surviving 
> Excel "upgrades". I will certainly try to avoid COM in the 
> future.

Each call of the COM interface is quite slow, but it seems to
be larglely independent of the amount of data transferred in
a call.  So the solution seems to be to transfer large chunks
at a time instead of individual cells:

     # get the content of an excel range as a list of lists
     data = my_excel_range.Value
     data = [list(row) for row in data]
     # manipulate the data inside python
     ...
     # transfer it back to excel in one go
     my_excel_range.Value = data

It's quite easy to access the entire used range of a worksheet
in this way:
 
     book = excelApp.Workbooks.Open(file_name)
     sheet = book.Sheets[sheet_name]
     my_excel_range = sheet.UsedRange


fritz



More information about the Python-list mailing list