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();

 

你可能感兴趣的:(Excel with COM)