Robbiblubber.Data.Util.CSV
CSV export for IEnumerable<T>: define columns and headers explicitly, select values through functions, and customise the output format.
What’s inside
- CsvExport<T> works with your data types; DataField<T> defines column order, headers, and value selection.
- Configure field and decimal separators, quotes, line endings, and file encoding.
- CsvOptions.GERMAN provides semicolon and decimal-comma defaults; header rows are optional.
- Write to a file, stream, TextWriter, or string using synchronous or asynchronous methods.
using Robbiblubber.Data.Util.CSV;
CsvExport<Product> export = new(
fieldDefinition:
[
new CsvExport.DataField<Product>("Name", p => p.Name),
new CsvExport.DataField<Product>("Price", p => p.Price)
],
csvOptions: CsvOptions.GERMAN.Clone());
await export.WriteToFileAsync("products.csv", [new Product("Notebook", 4.50m)]);
record Product(string Name, decimal Price);Two explicit columns, a header row, and German number formatting. Customise a copy of the options.
dotnet add package Robbiblubber.Data.Util.CSV