X++ code to create CSV file in ax 2012.
The TextIo,CommaIO are the classes used to create CSV files frequently.
In this post i'm using CommaIO class to create CSV file.
#static void CreateCSVFileJob(Args _args)#{
# CommaIO file;
# FileIOPermission fileIOPermission;
# str filename;
# #File
# ;
# /*
# if(!fileNameLocation)
# {
# throw error('file location is empty');
# }
# */
# filename = @'D:\test.csv';
# fileIOPermission = new FileIOPermission(fileName,"W");# fileIOPermission.assert();
# file = new CommaIo(fileName,"W");
# //Header
# file.inFieldDelimiter(',');
# file.write('CustomerNo','CustGroup','CustomerName');
# //Lines
# file.outFieldDelimiter(',');
# file.write('00101','10','vijay');# file.write('00102','20','bhaskar');
# file = null;
# CodeAccessPermission::revertAssert();# }
Thank You.
Comments
Post a Comment