How export data to csv file in Ax 2009

How export data to csv file in Ax 2009

Hi friends ,

   Today we will learn how to exporting our  data from Ax 2009 to csv file format. The programming is done through X++ code. Change the code as per your requirements. Now we will have a simple example of writing the invent table to the csv file


public static void main(Args _args)
{
    Commaio file;
    container line;
    InventTable inventTable;
    #define.filename("C:\\dpk_Items.csv")
    #File

    ;
    file = new Commaio(#filename , #io_write); or  file = new Commaio(#filename , 'W');
    //file.outFieldDelimiter(';');
    if( !file || file.status() != IO_Status::Ok)
    {
        throw error("File Cannot be opened");
    }
    while select inventTable
    {
        line = [inventTable.ItemId,inventTable.ItemName];
        file.writeExp(line);
    }
}

You can save the document in any format such as doc,txt,xls only.


-Harry

Comments

Popular posts from this blog

Connecting to Databases through X++ PART -I

X++ code for document attachment

Multiple Tables In Query