Showing posts with label export. Show all posts
Showing posts with label export. Show all posts

Jan 16, 2012

Export Datawindow to Excel

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..

Are legacy 4GL applications keeping you from embracing modern technologies?

As the competitive advantages offered by cloud, mobile, and other new technologies become more apparent, the decision to migrate legacy 4GL ...