2017-03-08

[AX 365] Create CSV File

This is a sample code to create csv file. It use CommaTextStreamIo class.

class RunnableClassExport2CSV
{       
    public static void main(Args _args)
    {   
        ATSGroupTable     groupTable;
        CommaTextStreamIo comma = CommaTextStreamIo::constructForWrite();
        ;
        while select groupTable
        {
            comma.writeExp([groupTable.GroupId, groupTable.Name]);
        }
        File::SendFileToUser(comma.getStream(), "atus.csv");
    }

}