CsvHelper.Excel.Core 15.0.5

An implementation of ICsvParser and ICsvSerializer from CsvHelper that reads and writes using the ClosedXml library.

Install-Package CsvHelper.Excel.Core -Version 15.0.5
dotnet add package CsvHelper.Excel.Core --version 15.0.5
<PackageReference Include="CsvHelper.Excel.Core" Version="15.0.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CsvHelper.Excel.Core --version 15.0.5
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

<!-- Build status -->

Discord Chat NuGet Badge

Csv Helper for Excel

CsvHelper for Excel is an extension that links 2 excellent libraries, CsvHelper and ClosedXml.
It provides an implementation of ICsvParser and ICsvSerializer from CsvHelper that read and write to Excel using ClosedXml.

ExcelParser

ExcelParser implements IParser and allows you to specify the path of the workbook or a stream.

When the path is passed to the constructor then the workbook loading and disposal is handled by the parser. By default the first worksheet is used as the data source.

using var reader = new CsvReader(new ExcelParser("path/to/file.xlsx"));
var people = reader.GetRecords<Person>();

When an instance of stream is passed to the constructor then disposal will not be handled by the parser. By default the first worksheet is used as the data source.


var bytes = File.ReadAllBytes("path/to/file.xlsx");

using var stream = new MemoryStream(bytes);
using var parser = new ExcelParser(stream);
using var reader = new CsvReader(parser);

var people = reader.GetRecords<Person>();
// do other stuff with workbook

All constructor options have overloads allowing you to specify your own CsvConfiguration, otherwise the default is used.

ExcelSerializer

ExcelSerializer implements ISerializer and, like ExcelParser, allows you to specify the path to which to (eventually) save the workbook or a stream.

When the path is passed to the constructor the creation and disposal of both the workbook and worksheet (defaultly named "Export") as well as the saving of the workbook on dispose, is handled by the serialiser.

using (var writer = new CsvWriter(new ExcelSerializer("path/to/file.xlsx")))
{
    writer.WriteRecords(people);
}

When an instance of stream is passed to the constructor the creation and disposal of a new worksheet (defaultly named "Export") is handled by the serialiser, but the workbook will not be saved.


using var stream = new MemoryStream();
using var serialiser = new ExcelParser(stream);
using var writer = new CsvWriter(serialiser);
writer.WriteRecords(people);
//other stuff
var bytes = stream.ToArray();

All constructor options have overloads allowing you to specify your own CsvConfiguration, otherwise the default is used.

<!-- Build status -->

Discord Chat NuGet Badge

Csv Helper for Excel

CsvHelper for Excel is an extension that links 2 excellent libraries, CsvHelper and ClosedXml.
It provides an implementation of ICsvParser and ICsvSerializer from CsvHelper that read and write to Excel using ClosedXml.

ExcelParser

ExcelParser implements IParser and allows you to specify the path of the workbook or a stream.

When the path is passed to the constructor then the workbook loading and disposal is handled by the parser. By default the first worksheet is used as the data source.

using var reader = new CsvReader(new ExcelParser("path/to/file.xlsx"));
var people = reader.GetRecords<Person>();

When an instance of stream is passed to the constructor then disposal will not be handled by the parser. By default the first worksheet is used as the data source.


var bytes = File.ReadAllBytes("path/to/file.xlsx");

using var stream = new MemoryStream(bytes);
using var parser = new ExcelParser(stream);
using var reader = new CsvReader(parser);

var people = reader.GetRecords<Person>();
// do other stuff with workbook

All constructor options have overloads allowing you to specify your own CsvConfiguration, otherwise the default is used.

ExcelSerializer

ExcelSerializer implements ISerializer and, like ExcelParser, allows you to specify the path to which to (eventually) save the workbook or a stream.

When the path is passed to the constructor the creation and disposal of both the workbook and worksheet (defaultly named "Export") as well as the saving of the workbook on dispose, is handled by the serialiser.

using (var writer = new CsvWriter(new ExcelSerializer("path/to/file.xlsx")))
{
    writer.WriteRecords(people);
}

When an instance of stream is passed to the constructor the creation and disposal of a new worksheet (defaultly named "Export") is handled by the serialiser, but the workbook will not be saved.


using var stream = new MemoryStream();
using var serialiser = new ExcelParser(stream);
using var writer = new CsvWriter(serialiser);
writer.WriteRecords(people);
//other stuff
var bytes = stream.ToArray();

All constructor options have overloads allowing you to specify your own CsvConfiguration, otherwise the default is used.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
15.0.5 4,721 8/13/2020
15.0.0 8,145 2/12/2020