In this article we will see how to Export table data in Comma Separated
file. Using Commaio it will help you to create comma separated file. Using the container will store the table’s row in container and save lines in
comma separated file. Using macro will save file in desktop otherwise where
ever you want to put you has to specify your path in macro like #defile.filename (““). Here is the
sample code how to read table data and export in Csv file. You can create Job otherwise if you want to put
it on button clicked event for your file. Here I have taken my custom table to
export table data in Csv file like (A_PurchaseOrder).
static void
ExportToCsv(Args _args)
{
Commaio file;
container line;
A_PurchaseOrder A_PurchaseOrder;
//InventTable inventTable;
#define.filename("C:\\Users\\umesh.adroja\\Desktop\\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 A_PurchaseOrder
{
line =
[A_PurchaseOrder.Purchase_ID,A_PurchaseOrder.Purchase_Date,A_PurchaseOrder.Vender_Code,A_PurchaseOrder.Status,A_PurchaseOrder.Purchase_Amount];
file.writeExp(line);
}
}
Thanks for comments.....