SimpleObjects2CSV 2.0.0

dotnet add package SimpleObjects2CSV --version 2.0.0
                    
NuGet\Install-Package SimpleObjects2CSV -Version 2.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SimpleObjects2CSV" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SimpleObjects2CSV" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="SimpleObjects2CSV" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SimpleObjects2CSV --version 2.0.0
                    
#r "nuget: SimpleObjects2CSV, 2.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SimpleObjects2CSV@2.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SimpleObjects2CSV&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=SimpleObjects2CSV&version=2.0.0
                    
Install as a Cake Tool

SimpleObjects2CSV

NuGet Version NuGet Downloads Build License .NET Tests

A tiny object-to-CSV exporter for simple .NET admin tools, tests, support dumps, and quick internal exports.

Convert a collection of plain objects into CSV using public properties as columns. No mapping profiles, no CSV reading, no heavy dependencies.

Install

dotnet add package SimpleObjects2CSV

Getting a CSV string

using SimpleObjects2CSV;

var people = new List<Person>
{
    new() { Name = "Alice", Age = 30 },
    new() { Name = "Bob", Age = 25 },
};

string csv = CSV.GetCSVString(people);
// Age,Name
// 30,Alice
// 25,Bob

IEnumerable<T> is supported:

string csv = CSV.GetCSVString(people.AsEnumerable());

List<string> exports each item as a single Value column:

string csv = CSV.GetCSVString(new List<string> { "alpha", "beta" });
// Value
// alpha
// beta

Writing a CSV file

// filename + directory (legacy API)
CSV.ExportCSV(people, "people.csv", @"C:\Exports");

// full file path
CSV.ExportCSV(people, @"C:\Exports\people.csv");

// write an existing CSV string
CSV.ExportCSV(csv, "people.csv", @"C:\Exports");

Directories are created automatically. Files are written as UTF-8 without BOM.

Skipping properties with [CsvIgnore]

public class User
{
    public string Name { get; set; }

    [CsvIgnore]
    public string Password { get; set; }
}

Custom column headers with [CsvName]

public class User
{
    [CsvName("Display Name")]
    public string FullName { get; set; }
}

Headers containing commas or quotes are escaped automatically.

Async export

await CSV.ExportCSVAsync(people, @"C:\Exports\people.csv");

await CSV.ExportCSVAsync(people, "people.csv", @"C:\Exports", cancellationToken: cancellationToken);

Formatting notes

  • Columns are ordered alphabetically by property name (not declaration order).
  • Column headers and values are CSV-escaped when they contain commas, quotes, or newlines.
  • List<string> / IEnumerable<string> exports each string as a single Value column.
  • Types with no exportable properties throw InvalidOperationException.
  • Duplicate [CsvName] headers on the same type throw InvalidOperationException.
  • Properties hidden with new on a derived type use the derived declaration.
  • Null property values export as empty fields.
  • Null items in the source collection are skipped (no row is written for them).
  • Numbers, decimals, floats, and doubles use invariant culture by default. Floats and doubles use round-trip (R) format.
  • DateTime, DateTimeOffset, DateOnly, and TimeOnly always use invariant ISO 8601 (O) format, regardless of IFormatProvider.
  • Booleans use invariant True/False text; IFormatProvider does not change them.
  • Pass an IFormatProvider to format numeric values with a specific culture:
string csv = CSV.GetCSVString(people, new CultureInfo("de-DE"));
CSV.ExportCSV(people, "people.csv", @"C:\Exports", new CultureInfo("de-DE"));
  • Async methods honour CancellationToken during file writes. On netstandard2.0, cancellation is checked between write chunks.

Security note

CSV files opened in spreadsheet applications may execute formulas when a cell value begins with =, +, -, @, or a tab character. Sanitise or prefix untrusted values if exports may be opened in Excel or similar tools.

License

Apache-2.0

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0 0 7/4/2026
1.0.0.2 1,513 4/28/2019