I\'m making a Python script which parses data files. The parsed data is then sent to an Excel file. The data can be rather huge. I\'m looking at 10 to 20 columns, but the nu
I know the post is a bit old.
However, being stuck with win32com for some other reason (macro executions) and needing a similar solution to your 3rd sheet way (complete array at once), I tried the code of your initial post and found a small mistake that prevented it to work.
So to answer your original question "What am I doing wrong?":
You forgot to re-initialize the row variable to 1 before using it in the '#no loop, write array to range' part.
Here is the win32com part of your comparison post updated then:
print "Writing using win32com.client"
start = time.time()
row = 1
sheet.Range(sheet.Cells(row,1), sheet.Cells(row+len(data_array)-1, len(data_array[0]))).Value = data_array
print "Processing time: " + str(time.time() - start) + " seconds."
book.SaveAs(Filename="C:\Temp\Temp.xls", FileFormat=56)
print "Completed: " + str(time.time() - start) + " seconds."
Then, timing is no so bad:
Writing using win32com.client
Processing time: 0.322000026703 seconds.
Completed: 1.73699998856 seconds.
Pretty fast then. Maybe your comparison can be updated since the PyExcelerate numbers are not so different anymore (and my computer is slower).