Page 1 of 1

Dumping to Excel

Posted: Mon Jun 17, 2002 3:42 pm
by toppac
How can I dump a recordset to an Excel file. I am using the OCI to run a sql query and I need to dump the result set to an Excel spreadsheet

Posted: Mon Jun 17, 2002 4:19 pm
by mikeq
Hi,

I just create a comma seperated file with all the records, when opened in Excel a wizard appears to help importing the file.

So logic is

Open a file for writing.
Open result set.
Iterate through result set concatenating field values with commas in between.
Write concatenated string to file.
repeat for each row.
Close file.

Hope this helps

Posted: Mon Jun 17, 2002 4:39 pm
by toppac
Thanks, that will work. Now can you point me to the class/functions to do that with? I am not sure how to write to flatfiles.

Posted: Tue Jun 18, 2002 3:34 am
by e+
on a side note if you use

Fields terminated by = ,
Fields enclosed by = “
Fields escaped by = \
Lines terminated by = \r\n

Excel won't run the wizard and will just open the file.

Posted: Wed Jun 19, 2002 8:45 am
by mikeq
toppac wrote:Thanks, that will work. Now can you point me to the class/functions to do that with? I am not sure how to write to flatfiles.
You will find them here