CsvHelper

 from https://stackoverflow.com/questions/18757097/writing-data-into-csv-file-in-c-sharp



create csv

using(var textWriter = new StreamWriter(@"C:\mypath\myfile.csv"))
{
    var writer = new CsvWriter(textWriter, CultureInfo.InvariantCulture); 

    foreach (var item in list)
    {
        writer.WriteField( "a" );
        writer.WriteField( 2 );
        writer.WriteField( true );
        writer.NextRecord();
    }
}


留言

熱門文章