I\'m using CsvHelper
class to write rows in DataTable
to a csv file. The code works but I can\'t get it to write the headers.
How can I add the
The easiest way is to use
writer.WriteHeader();
More complete example:
using (StreamWriter sw = new StreamWriter(@"C:\output.csv"))
{
using (CsvWriter writer = new CsvWriter(sw))
{
writer.WriteHeader();
writer.WriteRecord(yourRecordVariable);
}
}
As was posted here on Google groups by the author Josh Close.