Creating excel file in axapta


 CustTable custTable;  
 SysExcelApplication application;  
 SysExcelWorkbooks workbooks;  
 SysExcelWorkbook workbook;  
 SysExcelWorksheets worksheets;  
 SysExcelWorksheet worksheet;  
 SysExcelCells cells;  
 SysExcelCell cell;  
 int row;  
 ;  
 application = SysExcelApplication::construct();  
 workbooks = application.workbooks();  
 workbook = workbooks.add();  
 worksheets = workbook.worksheets();  
 worksheet = worksheets.itemFromNum(1);  
 cells = worksheet.cells();  
 cells.range('A:A').numberFormat('@');  
 while select custTable  
 {  
 row++;  
 cell = cells.item(row, 1);  
 cell.value(custTable.AccountNum);  
 cell = cells.item(row, 2);  
 cell.value(custTable.Name);  
 }  
 application.visible(true);  
 }