Skip to main content

Posts

Showing posts with the label export to excel through code

Import data from axapta table to excel through code

SysExcelApplication ExcelApplication; SysExcelWorkBooks ExcelWorkBooks; SysExcelWorkBook ExcelWorkBook; SysExcelWorkSheets ExcelWorkSheets; SysExcelWorkSheet ExcelWorkSheet; SysExcelRange ExcelRange; CustTable custTable; int row=1; ExcelApplication = SysExcelApplication ::construct( ); ExcelApplication. visible(true) ; ExcelWorkBooks = ExcelApplication. workbooks( ); ExcelWorkBook = ExcelWorkBooks. add(); ExcelWorkSheets = ExcelWorkBook. worksheets( ); ExcelWorkSheet = ExcelWorkSheets. itemFromNum( 1); ExcelWorkSheet. cells().item( row,1).value( 'Account num'); ExcelWorkSheet. cells().item( row,2).value( 'Name'); row++; while select custTable where custtable.AccountNum like 'c-000*' { ExcelWorkSheet. cells().item( row,1).value( custTable. AccountNum) ; ExcelWorkSheet. cells().item( row,2).value( custTable. Name); row++; } ExcelApplication. finalize( );