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

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.