Dominick Lauzon wrote:

I have large matrices of data to push to excel and I find the writing of
data to excel to be excessively slow (cell by cell method) even if the
Visible is to False.


Right now I reverted back to a 2 step CSV - Import to Excel but it is
far from ideal.


Is there any trick to accumulate the data and push it to Excel all at
once or any other way to improve performance altogether ?


Using COM (which I assume you are from the reference to Visible)
you can add a range at a time as a Python list or list of lists:

<code>
import win32com.client

xl = win32com.client.gencache.EnsureDispatch ("Excel.Application")
xl.Visible = True
sheet = xl.Workbooks.Add ().ActiveSheet
sheet.Range (sheet.Cells (1, 1), sheet.Cells (10, 10)).Value = \
 [range (10) for i in range (10)]

</code>


I suspect -- tho' I've never tried to find out -- that using something
like xlwt (and when I say "something like xlwt" I really mean "xlwt")
might be faster since it doesn't have to manipulate the interface at the
same time:

http://pypi.python.org/pypi/xlwt


Lastly there is a Google Group set up for Python-Excel issues and
you might want to lurk or ask there:

http://groups.google.com.au/group/python-excel

TJG
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to