CsvHelper icon indicating copy to clipboard operation
CsvHelper copied to clipboard

[Feature request] Anonymous type and dictionary support

Open alexeygritsenko opened this issue 8 months ago • 1 comments

Hi, there is a cool idea that you can borrow from MiniExcel

1. Anonymous type support

csv.WriteRecords(new[] {
    new { Column1 = "MiniExcel", Column2 = 1 },
    new { Column1 = "Github", Column2 = 2}
});

2. Dictionary support

var values = new List<Dictionary<string, object>>()
{
    new Dictionary<string,object>{{ "Column1", "MiniExcel" }, { "Column2", 1 } },
    new Dictionary<string,object>{{ "Column1", "Github" }, { "Column2", 2 } }
};
csv.WriteRecords(values);

Source sample data:

Column1 Column2
MiniExcel 1
Github 2

alexeygritsenko avatar Jun 10 '24 14:06 alexeygritsenko