Re: Extremely slow performance with getCellByPosition

Bernard Marcelly <[email protected]>
Newsgroups gmane.comp.openoffice.devel.api
Message-ID <[email protected]>
Hi,

I used OOoBasic, which is not really fast.
For the test my sheet had numbers on the first 637 rows, but the macro runs on 
27001 rows.

Sub Main
Dim sh As Object, myCell As Object
Dim x As Long, y As Long, t As Long

sh = ThisComponent.Sheets(0)
t = GetSystemTicks
for y =  0 to 27000
   for x = 0 to 32
     myCell = sh.getCellByPosition(x,y)
   next
next
MsgBox("Duration : " & GetSystemTicks -t & " milliseconds")
End Sub

Result : approx. 110 seconds (less than 2 minutes)
Windows XP SP3, Intel Core 2CPU at 2.13 GHz

Your spreadsheet probably has something special. Or you do something else in the 
loop.
Try to load the csv version instead of the original Excel file.

Regards
   Bernard

Message de Andrew Pitonyak  date 2010-11-08 00:04 :
>
> On Fri, 5 Nov 2010 21:24:08 -0400, Scott Deerwester
> <[email protected]>  wrote:
>> The following code (in Python):
>>
>> for r in range(dataRange.StartRow, dataRange.EndRow):
>>      for c in range(dataRange.StartColumn, dataRange.EndColumn):
>>          cell = sheet.getCellByPosition(c,r)
>>
>>
>> takes nearly two hours to run on a reasonably fast workstation for a
>> spreadsheet with 32 columns and ~27,000 rows (about .2 seconds per row).
> By
>> comparison, opening the file takes about 8 seconds and saving the file
> to a
>> CSV (which is functionally equivalent to the above) takes a few seconds.
>> The
>> original file was written in Excel as an XLS (not XLSX). This seems
>> impossibly slow. Am I misusing the API somehow? What can I do to speed
> it
>> up?
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.