Board index » delphi » Writing to a tab delimited text file from a query

Writing to a tab delimited text file from a query

I have a delphi program that retrieves a query from access and writes the
results line by line to a tab-delimited text file.  I save the file with a
.xls extension and excel opens it just like an excel file.  My problem is
that sometimes my result set is very large and the file can take hours to
write to.  I think my method is too slow.  I toyed with the idea of opening
the set to a grid (i use dxDBGrid) and using the grid's .savetoxls method.
Does anyone know if this would be just as slow?  Can anyone tell me a better
way to write to an excel or text file from a query results set?

thanks in advance,
Jeff

 

Re:Writing to a tab delimited text file from a query


Quote
"Jeff Burgoon" <jburg...@sakon.com> wrote in message

news:3cc6bbc9$1_2@dnews...

Quote
> I have a delphi program that retrieves a query from access and writes the
> results line by line to a tab-delimited text file.  I save the file with a
> .xls extension and excel opens it just like an excel file.  My problem is
> that sometimes my result set is very large and the file can take hours to
> write to.  I think my method is too slow.  I toyed with the idea of
opening
> the set to a grid (i use dxDBGrid) and using the grid's .savetoxls method.
> Does anyone know if this would be just as slow?  Can anyone tell me a
better
> way to write to an excel or text file from a query results set?

ADO RecordSets have a GetString method to return the results as a
widestring, with whatever column and row delimiter you want. You could then
save the string to file. Try that and see if it's any faster.
e.g.

uses ADOInt;
...
  MyCommaString := ADODataSet1.Recordset.GetString(adClipString, -1, #9,
#13, '');

Andy Mackie.

Other Threads