Thursday 9 January 2014

Export data from Ax 2009 to Excel file in Ax 2009

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();
cells.range('A:A').numberFormat('@');
while select custTable
//The following loop will provide the data to be populated in each column
{
row++;
cell = cells.item(row,1);
cell.value(custTable.AccountNum);
cell = cells.item(row,2);
cell.value(custTable.Name);
cell = cells.item(row,3);
cell.value(CustTable.CustGroup);
cell = cells.item(row,4);
cell.value(CustTable.Currency);
cell = cells.item(row,5);
cell.value(CustTable.CreditMax);
cell = cells.item(row,6);
cell.value(CustTable.CreditRating);
}
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

No comments:

Post a Comment

SQL/SSRS Interview questions I thought of blogging some SQL/SSRS interview questions.

Below are some. I will add more, when I complete the compilation 1. What is OLTP(Online Transaction Processing)? OLTP stands ...