Excel and COM -- Another question

Eric Hagemann ehagemann at home.com
Mon May 15 19:49:11 EDT 2000


Hello,

I am using Python to control Excel via COM with the desire to push a large
amount of data ~10K pieces from Python into excel.  I have used the
functions in the "Python Programming on Win32" Book (P149/150) with success
to place single items into single cells based on an x,y coordinate thing.
Problem is that with large numbers of data points the function call overhead
can be intense ( each data sample requires a COM call)

Also provided in the book is a function 'setRange' that allows 'blocks' of
data to be sent in a single call -- Just what the doctor ordered -- well
kinda.  It seems this function takes lists or tuples and places them into
excel row wise.   So that when I type

sheet.Range("A1:C1").Value = [1,2,3] I get A1=1,B1=2,and C1=3

if I use

sheet.Range("A1:A3").Value = [1,2,3] I get A1=1,A2=1 and A3=1

where the first item in the list is repeated, confirmed with other numbers,

However if I use sheet.Range("A1:A3").Value = [[1],[2],[3]] then I get
A1=1,A2=2 and A3=3 as desired.

Since my data is already nicely in a list I am trying to avoid having to
reform into into a list of one long lists.  Any suggestions ?

You might be asking what is wrong with using the data in a row wise form ?
Well excel only supports 256 columns, while it supports 65536 rows


Cheers
Eric








More information about the Python-list mailing list