exporting to xls format

gaurab

New Member
Hiee e'body .. i am trying to export tables of DB into Excel. And i am also been successful doing like this :

/**************************************************/

DEFINE VARIABLE hExcel AS COM-HANDLE.
DEFINE VARIABLE hws AS COM-HANDLE.
DEFINE VARIABLE hwb AS COM-HANDLE.

CREATE "Excel.Application" hExcel.
IF NOT VALID-HANDLE(hExcel) THEN RETURN.
hExcel:Visible = true .

hwb = hExcel:WorkBooks:ADD.
hws = hwb:worksheets:ADD .

RELEASE OBJECT hws.
RELEASE OBJECT hwb.
RELEASE OBJECT hExcel.

/****************************************************/

But my problem is i want to generate this excel file in a particular location i want with the name i give. I belive this could be done with small modifications on the code above but i am unable to do that.

Please help me out of this.

Regards,

Gaurab.
 
Hi Gaurab,

Try this, I hope it will get you on your way.

DEFINE VARIABLE hExcel AS COM-HANDLE.
DEFINE VARIABLE hws AS COM-HANDLE.
DEFINE VARIABLE hwb AS COM-HANDLE.

CREATE "Excel.Application" hExcel CONNECT TO <xls-file>.
IF NOT VALID-HANDLE(hExcel) THEN RETURN.
hExcel:Visible = true .

hwb = hExcel:WorkBooks:open("<xls-file>").

RELEASE OBJECT hws.
RELEASE OBJECT hwb.
RELEASE OBJECT hExcel.


Greetings,
Ruud
 
Thank u all guys...

hExcel:ActiveSheet:SaveAs(cFilename).

works fine for me and even the link posted by Casper is pretty useful.

thanks again.

Gaurab.:D:D:D
 
Back
Top