ArturRios.Data.Export 1.0.3

dotnet add package ArturRios.Data.Export --version 1.0.3
                    
NuGet\Install-Package ArturRios.Data.Export -Version 1.0.3
                    
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="ArturRios.Data.Export" Version="1.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ArturRios.Data.Export" Version="1.0.3" />
                    
Directory.Packages.props
<PackageReference Include="ArturRios.Data.Export" />
                    
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 ArturRios.Data.Export --version 1.0.3
                    
#r "nuget: ArturRios.Data.Export, 1.0.3"
                    
#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 ArturRios.Data.Export@1.0.3
                    
#: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=ArturRios.Data.Export&version=1.0.3
                    
Install as a Cake Addin
#tool nuget:?package=ArturRios.Data.Export&version=1.0.3
                    
Install as a Cake Tool

ArturRios.Data.Export

NuGet Docs License: MIT

File writers for the ArturRios.Data toolkit: turn any IEnumerable<T> into CSV, JSON, TXT, or MessagePack, over a stream or straight to a file.

Like the rest of the family, every write returns a ProcessOutput envelope — a locked file or a serialization failure comes back as an error on the result instead of an unhandled exception.

This package is standalone: it works with plain POCOs and does not need any of the data-access packages. For Excel (.xlsx), add the ArturRios.Data.Export.Excel add-on.

Installation

dotnet add package ArturRios.Data.Export
dotnet add package ArturRios.Data.Export.Excel        # optional — adds ExportFormat.Excel

Requires .NET 10.0 or later.

Quick start

1. Register (Program.cs):

using ArturRios.Data.Export.DependencyInjection;

builder.Services.AddExport();

2. Resolve an exporter and write:

using ArturRios.Data.Export.Abstractions;
using ArturRios.Output;

public class ProductReport(IExporterFactory exporters)
{
    public async Task<ProcessOutput> WriteCsvAsync(IEnumerable<Product> products, string path)
    {
        var exporter = exporters.Resolve<Product>(ExportFormat.Csv);
        return await exporter.WriteToFileAsync(products, path);
    }
}

You can also inject a concrete exporter directly (CsvExporter<Product>, JsonExporter<Product>, …) when the format is fixed at compile time. Both WriteAsync(data, stream) and WriteToFileAsync(data, path) are available; the stream overload does not dispose your stream.

Formats

ExportFormat Exporter Notes
Csv CsvExporter<T> RFC 4180 quoting/escaping, configurable delimiter and encoding
Json JsonExporter<T> a JSON array via System.Text.Json
Txt TxtExporter<T> one line per record; ToString() or a custom line selector
MessagePack MessagePackExporter<T> binary, contractless resolver — no attributes required
Excel (add-on) requires ArturRios.Data.Export.Excel and AddExcelExport()

Resolving ExportFormat.Excel without the add-on registered throws a NotSupportedException that says exactly which package and call are missing.

Shaping columns

The columnar formats (CSV and Excel) build their column plan from the record's public readable properties. Two attributes let you adjust it:

using ArturRios.Data.Export.Attributes;

public class Product
{
    [ExportColumn(Name = "Product name", Order = 1)]
    public string Name { get; set; } = string.Empty;

    [ExportColumn(Order = 2)]
    public decimal Price { get; set; }

    [ExportIgnore]
    public string InternalNotes { get; set; } = string.Empty;
}

Columns sort by Order ascending; unordered columns sort last. The plan is compiled to delegate getters and cached per type, so there is no per-row reflection cost.

Values are rendered culture-invariantly: null becomes empty, strings pass through, and anything IFormattable is formatted with CultureInfo.InvariantCulture.

Options

AddExport() takes an optional configuration callback:

builder.Services.AddExport(options =>
{
    options.Csv.Delimiter = ';';
    options.Csv.IncludeHeader = true;
    options.Json.WriteIndented = true;
    options.Txt.NewLine = "\n";
});

Both Json and MessagePack also accept explicit SerializerOptions, used as-is when set.

Documentation

Licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on ArturRios.Data.Export:

Package Downloads
ArturRios.Data.Export.Excel

Excel (.xlsx) export add-on for ArturRios.Data.Export

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.3 36 7/24/2026
1.0.2 37 7/23/2026
1.0.1 102 7/15/2026
1.0.0 101 7/15/2026