Thursday, August 7, 2008

Export a Document to Excel in Axapta using X++

static void MouliExcel(Args _args)
{
EmplTable EmplTableLocal;
SysExcelApplication excelApp;
SysExcelWorkSheet excelWorksheet;
SysExcelRange excelRange;
SysExcelCells excelCells;
SysExcelCell excelCell;
ComVariant cellValue;
Int i=1;
;
excelApp = SysExcelApplication::construct();
cellValue = new ComVariant() ;
excelApp.workbooks().add();
excelWorksheet = excelApp.worksheets().itemFromNum( 1 );
excelCells = excelWorksheet.cells();
while select * from EmplTableLocal
{
excelCells.item(i+4,4).value(cellValue.bStr(EmplTableLocal.EmplId));
excelCells.item(i+4,5).value(cellValue.bStr(EmplTableLocal.Name));
i++;
}
excelApp.visible(true);
//excelApp.quit();
}

No comments: