Export Datawindow to excel files without dw2xls
First, create a global function
f_excel(datawindow idw)
int li_rtn
string xlsname,nama, ls_alamat
//Check for row(s) in datawindow
if idw.rowcount( ) <= 0 then
messagebox(' Export Excel','No rows to export!')
return
end if
//excel file save directory
li_rtn = GetFileSaveName( "Select File", &
xlsname, nama, "", &
"Excel 97-2003 Workbook(*.xls) ,*.*,")
if idw.saveas( xlsname+'.xls' , htmltable!, TRUE ) = -1 then
MessageBox(" Warning", "error!",Exclamation! )
return ;
end if ;
oleobject excel ;
excel = create oleobject ;
if excel.connecttoobject(xlsname+ '.xls' ) = 0 then
Excel.Application. DisplayAlerts = false ;
Excel.Application. Workbooks( 1 ).Parent.Windows
Excel.Application. workbooks( 1 ).Name ).Visible true ;
Excel.Application. Workbooks( 1 ).SaveAs(xlsname+ '.xls', 39 ) ;
Excel.Application. Workbooks( 1 ).close() ;
messagebox(' Export Excel','datawindow exported succesfully!')
run("c:\windows\ explorer. exe "+xlsname+'. xls')
end if ;
destroy excel
Sample usage : f_excel(dw_customer)
Cheers..