Ricardo Aráoz wrote:
> 
> My reports  generate Excel files, if the report is too long (more than
> 64000 lines) I use different pages in the same file. I have two ways to
> do it, either I export up to say 15000 lines with a copy to command to a
> temporary excel file, then open it (as an excel object), copy it's
> contents to the clipboard (through excel command) and then copy the
> clipboard to a new page in my multi page excel file. The pro of this
> method is speed, the con is that if the customer uses the clipboard he
> interferes with the report.
> The other way is to insert the data cell by cell, but if the file is too
> large it gets slow.
> Does any of you know of some other way to optimize this?


Ricardo,

The easiest and fastews way, imo, is to read the data with ado, next use 
the copyfromrecordset method to copy to excel.

It will be fast and you don't have to deal with the volatile clipboard.

*Create ado connection and recordset object
loConn = NewObject('ADODB.Connection')
loRs = NewObject('adodb.recordset')
loconn.ConnectionString = "Provider=vfpoledb.1;Data 
Source=C:\myvfpdbfolder\;Collating Sequence=general;"
loconn.Open
lors.Open("select * from credidt.dbf", LoConn)

*excel object:
loExcel = NewObject("Excel.application")
loWorkBook = loexcel.Workbooks.Add
loWorkSheet = loexcel.ActiveWorkbook.Worksheets.Add
loExcel.visible = .T.   
loworksheet.range("A1").CopyFromRecordset(lors) && copy data to excel



HTH




Saludos,
Jaime Vasquez
Guatemala C.A.



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/[EMAIL PROTECTED]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to