lingdanglfw(DAX)

导航

Excel with COM

COM     excelApplication ;    

COM     workBooks ;     

COM     workSheets ;     

COM     workSheet ;     

COM     workBook ;     

COM     activesheet ;     

COM     cells ;     

COM     cell ;     

COM     selections ;     

COM     Range ;     

COM     Font ;     

int     a,b  ;     

;

 

excelApplication        = new COM("excel.application") ;     

excelApplication.visible(true);     

workBooks               = excelApplication.workbooks();     

workBooks.open("C:\\AX.xls");    //create a xls file first

 

     workBook                = workbooks.item(1) ;

 

     workSheets              = workBook.worksheets() ;     

//workSheet               = workSheets.add();  //add a sheet, yes or no     

activesheet             = worksheets.item(1) ;

 

    b       = 0 ;

 

//export var data     

for(a=1;a<30;a++)     

{         

b                       = b+1 ;         

range                   = activesheet.range("A"+int2str(a)) ;         

range.value2(int2str(b+1)) ;         

font = range.font();         

font.size(20);         

font.name("Arial") ;     

}  //The below is export database data    

while select name from empltable

where empltable.EmplId == '028'     

{         

range                   = activesheet.range("A1") ;         

range.value2(empltable.Name) ;         

font = range.font();         

font.size(20);         

font.name("Arial") ;     

}  

//quit and save     

workBook.save() ;     

workBook.close() ;     

excelApplication.quit();

 

posted on 2015-08-04 15:10  lingdanglfw  阅读(165)  评论(0编辑  收藏  举报