Export data to Excel from X++ / Ax

Dear Community,

Would like to know is it possible to call and use excel data validation object from X++?

Preview:

I couldn’t post the excel data validation screenshot here. And i posted in my dropbox:

dl.dropboxusercontent.com/…/123.jpg

Please kindly advise

Thanks,

Hi Qiwei,

I am assuming that you are trying to export data in a table to a export file.

I considered custTable Table data. In that, I am exporting the data of AccountNum and Name.

Here is the code and doing it through a job. Please use the code as per your requirements.

static void CreateExcelFile(Args _args)

{

CustTable custTable;

SysExcelApplication excel;

SysExcelWorkbooks workbooks;

SysExcelWorkbook workbook;

SysExcelWorksheets worksheets;

SysExcelWorksheet worksheet;

SysExcelCells cells;

SysExcelCell cell;

int row;

excel = SysExcelApplication::construct();

workbooks = excel.workbooks();

workbook = workbooks.add();

worksheets = workbook.worksheets();

worksheet = worksheets.itemFromNum(1);

cells = worksheet.cells();

cells.range(‘A:A’).numberFormat(’@’);

while select custTable

{

row++;

cell = cells.item(row+1, 2);

cell.value(custTable.AccountNum);

cell = cells.item(row+1, 3);

cell.value(custTable.name());

}

excel.visible(true);

}

Hi Qiwei,

I am assuming that you are trying to export data in a table to a export file.

I considered custTable Table data. In that, I am exporting the data of AccountNum and Name.

Here is the code and doing it through a job. Please use the code as per your requirements.

static void CreateExcelFile(Args _args)

{

CustTable custTable;

SysExcelApplication excel;

SysExcelWorkbooks workbooks;

SysExcelWorkbook workbook;

SysExcelWorksheets worksheets;

SysExcelWorksheet worksheet;

SysExcelCells cells;

SysExcelCell cell;

int row;

excel = SysExcelApplication::construct();

workbooks = excel.workbooks();

workbook = workbooks.add();

worksheets = workbook.worksheets();

worksheet = worksheets.itemFromNum(1);

cells = worksheet.cells();

cells.range(‘A:A’).numberFormat(’@’);

while select custTable

{

row++;

cell = cells.item(row+1, 2);

cell.value(custTable.AccountNum);

cell = cells.item(row+1, 3);

cell.value(custTable.name());

}

excel.visible(true);

}