Making exports to Excel faster [message #379380] |
Tue, 06 January 2009 04:33 |
jury
Messages: 1 Registered: January 2009
|
Junior Member |
|
|
Hi
I'm exporting data from forms to Excel using client_ole2. It works fine
but the performance is so terrible, its so slow. Is there any way to
improve it ? When doing the same thing in Delphi I used VarArray to
dump all data in it and than sending it to Excel in one pass, this way
even a lot of data was exported very quickly, it looked like this:
arrData: Variant;
begin
arrData := VarArrayCreate([1, yourStringGrid.RowCount, 1,
yourStringGrid.ColCount], varVariant);
{fill array}
for i := 1 to yourStringGrid.RowCount do
for j := 1 to yourStringGrid.ColCount do
arrData[i, j] := yourStringGrid.Cells[j-1, i-1];
{initialize an instance of Excel}
...
{retrieve a range where data must be placed}
Range := wb.WorkSheets[1].Range[wb.WorkSheets[1].Cells[1, 1],
wb.WorkSheets[1].Cells[yourStringGrid.RowCount, yourStringGrid.ColCount]];
{copy data from allocated variant array}
Range.Value := arrData;
end;
This method doesn't want to run in Forms, because CLIENT_OLE2.SET_PROPERTY doesnt want
to accept any arrays. Do anybody know how to make export through client_ole2 much
faster ?
jury
"how far can they control my mind"
|
|
|
Re: Making exports to Excel faster [message #380001 is a reply to message #379380] |
Thu, 08 January 2009 18:43 |
|
djmartin
Messages: 10181 Registered: March 2005 Location: Surges Bay TAS Australia
|
Senior Member Account Moderator |
|
|
Then use Delphi, or utl_file to a 'csv' file, or search this forum for 'excel again' and look at the list of good Excel topics and see if they contain any hints.
David
|
|
|