public void exportCSV(str _filename)
    {
        CommaStreamIo io = CommaStreamIo::constructForWrite();
        str filename = strFmt('%1.csv', _filename);
        
        SalesTable salesTable;

        //write the header
        io.writeExp(['SalesId','DlvMode']);
        
        while select salesTable
            where salesTable.DataAreaId = curExt()
        {
            io.writeExp([SalesTable.salesId, SalesTable.DlvMode]);
        }

        //Get the stream
        System.IO.Stream stream = io.getStream();
        stream.Position = 0 ;

        //StreamReader to read as str
        System.IO.StreamReader reader = new System.IO.StreamReader(stream);
        str csvFileContent = reader.ReadToEnd();

        //save file
        File::SendStringAsFileToUser(csvFileContent, filename);

    }

文章標籤
創作者介紹
創作者 lionlionchopper 的頭像
lionlionchopper

呆子獅的夢想世界

lionlionchopper 發表在 痞客邦 留言(0) 人氣()