Export data to Excel using X++


Below sample code used to export data from Ax to Excel or text.

static void CSV_excel(Args _args)
Commaio file;
container line,header;
HcmWorker hcmWorker;
#define.filename(“C:\\dpk_Items3.csv”) //if we need text file to be genetated: use “.txt” as extension for the file”

file = new Commaio(#filename , #io_write);// or file = new Commaio(#filename , ‘W’);
if( !file || file.status() != IO_Status::Ok)
throw error(“File Cannot be opened”);
header = [‘Empl code’,’..’, ‘recid’];
while select hcmWorker
line = [hcmWorker.TransferEmployeeCode,’…’,hcmWorker.RecId];



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s