.net - How to add header using Filehelper with DataTableToCSV -


i using:

datatabletocsv(datatable,filepath) 

to create csv file. generating perfect csv. how add column names when using datatabletocsv?

you can use following:

[delimitedrecord(","), ignorefirst(1)] public class person {     // must specify fieldorder     [fieldorder(1), fieldtitle("name")]     string name;      [fieldorder(2), fieldtitle("age")]     int age; }  ...  var engine = new filehelperengine<person> {     headertext = typeof(person).getcsvheader() };  ...  engine.writefile(@"c:\people.csv", people); 

reference https://gist.github.com/1391429


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -