Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exporting DataTable using FileHelpers

I want to export the contents of a DataTable to a text delimited file using FileHelpers, is this possible? Here is what I have so far:

// dt is a DataTable with Rows in it
DelimitedClassBuilder cb = new DelimitedClassBuilder("MyClassName", "|", dt);
Type t = cb.CreateRecordClass();
FileHelperEngine engine = new FileHelperEngine(t);

I have to convert the contents of dt to an array of type "MyClassName" but I'm not sure how to do that? I know there is a FileDataLink class but none of them work with DataTable (or even a DataSet).

like image 434
Nick Dat Le Avatar asked Mar 06 '26 06:03

Nick Dat Le


1 Answers

Maybe you could use this:

CommonEngine.DataTableToCsv(dt, "customers.csv", '|');
like image 102
Petros Avatar answered Mar 08 '26 20:03

Petros



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!