Tuesday, 20 December 2011

Export data from Ax 2009 to Excel file in Ax 2009

Hi friends,
Today I am going to say how to export data from Ax 2009 to Excel sheet through code . The code is , open the class , new class in class declaration type
class ExcelExport
and right click and select new method and type the code as follows
public static void main(Args args)
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();
while select custTable
//The following loop will provide the data to be populated in each column
cell = cells.item(row,1);
cell = cells.item(row,2);
cell = cells.item(row,3);
cell = cells.item(row,4);
cell = cells.item(row,5);
cell = cells.item(row,6);
application.visible(true); // opens the excel worksheet
By this code you can export all the customers to excel and this export can also be done on other ways
In Administration-->Periodic--->Data export/import---->Excel speardsheets--->Template wizard
In this template wizard ---->Next--->Open workbook(create an excel file with it)--->next--->Available objects(tables) and move your required tables to Selected objects--->Next--->Select the fields(if required)--->Create Import definition group--->Check Export data and Finish...
I think this code will help in exporting to excel
Vivek Chirumammilla.

No comments:

Post a Comment