Create a CSV file in D365FO using x++.
commaStreamIo iO = commaStreamIo::constructForWrite(); Filename filename = "MyFile.csv"; // Field List container header = ["Account Number", "Name", "Ph no"]; iO.writeExp(header); header = conNull(); while select myTable { container line = [myTable.AccountNumber, myTable.Name, myTable.PhNo]; iO.writeExp(line); } System.IO.Stream stream = iO.getStream(); stream.Position = 0; System.IO.StreamReader reader = new System.IO.StreamReader(stream); str csvFileContent = reader.ReadToEnd(); File::SendStringAsFileToUser(csvFileContent, filename); info(strFmt("CSV file %1 is created", filename));
Keep Daxing!!
No comments:
Post a Comment