Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Very Slow Second Sheet
Message
From
21/04/2017 08:59:29
 
 
To
21/04/2017 08:45:55
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
01650494
Message ID:
01650506
Views:
54
>>Hi All:
>>
>>I'm trying to process an Excel spreadsheet via VFP 9. I've got a main form which sets up some parameters and an OK button to start the processing. In the OK button I have
>>oxl = CREATEOBJECT("excel.application")
>>oxl.displayalerts = .F.
>>oxl.workbooks.add
>>owb = oxl.activeworkbook
>>.
>>.
>>.
>>If thisform.chkDetail.value
>>    thisform.mCreDtl
>>    thisform.mCreDtlMYR
>>ENDIF
>>.
>>other similar calls.
>>.
>>
In the beginning of each of the two methods I have
>>owb.Sheets.Add  && owb from calling button
>>osh = owb.ActiveSheet
>>osh.name = 'Creditors Detail'
>>
>>r1 = 1
>>rb = r1
>>    
>>
>>WITH osh
>> etc
>>
>>The two methods are very similar and process roughly the same amount of data. The first one (mCreDtl) is slow, but not unreasonable -- about 2 minutes.
>>The second one (mCreDtlMYR) takes almost fifteen minutes to complete.
>>
>>Because the two methonds are not dependent on each other, I can reverse the sequence in which they are called.
>>I do that with the same results. The first one to run (mCreDtlMYR) is slow, but not unreasonable.
>>The second one (mCreDtl) takes almost fifteen minutes to complete.
>>
>>I tried forcing osh to NULL at the end of the methods, but that had no impact.
>>I've also tried a FLUSH and SYS(1104), but that had no impact.
>>
>>My only thought at the moment is to save each worksheet in a separate file, close XL at the end of each method and then try to combine them into one spreadsheet
>>once the individual methods have completed.
>>
>>Is there other approach I can take to get the processing up to speed?
>>
>
>Not sure what's going on, but in general, COPY TO followed by opening a workbook is much faster than populating it cell by cell. So I think you can speed both pages up by writing out new workbooks, and then using copy/paste to move the date where you want it.
>
>Tamar

Right, and the easiest way to copy a table to the clipboard is
Select * From yourtable Where YourCondition Into Cursor CurDummy
_vfp.DataToClip(,,3)
Previous
Reply
Map
View

Click here to load this message in the networking platform