Table of Contents

Class ExcelParser<T>

Namespace
ExcelReader.Core.Parser
Assembly
ExcelReader.Core.dll

Parses rows from an Excel or CSV sheet into instances of T. Create one with ExcelParser: FromAttributes<T>(ExcelParserOptions?) reflects over [ExcelColumn]/[ExcelRequired]/[ExcelConverter] attributes, Generated<T>(ExcelParserOptions?) uses the [ExcelSerializable] source-generated map, and Build<T>(Action<ExcelRowMapBuilder<T>>, ExcelParserOptions?) takes a map configured at runtime.

public sealed class ExcelParser<T> where T : allows ref struct

Type Parameters

T

The model type to bind each row to. May be a ref struct, including one with a ReadOnlySpan<byte> property. A struct T consumed via a direct foreach skips the per-row model allocation a class T requires.

Inheritance
ExcelParser<T>
Inherited Members

Methods

Parse(CsvSheet)

Parses the records of a CSV sheet into T instances, lazily as the result is enumerated.

public CsvEnumerable<T> Parse(CsvSheet sheet)

Parameters

sheet CsvSheet

The CSV sheet to pull records from.

Returns

CsvEnumerable<T>

An enumerable that yields one T per data row.

Remarks

Uses a specialized enumerable (dense field binding, single-pass projection), since CSV rows have no gaps or styles. Prefer this overload over Parse(IExcelSheet) for CSV: a sheet held as IExcelSheet goes through the generic path.

Parse(IExcelSheet)

Parses the rows of a format-agnostic sheet (one obtained from IExcelWorkbook) into T instances, lazily as the result is enumerated.

public ExcelEnumerable<T, IExcelSheet, IExcelRowEnumerator> Parse(IExcelSheet sheet)

Parameters

sheet IExcelSheet

The sheet to pull rows from. Each enumeration of the result starts a new read of it.

Returns

ExcelEnumerable<T, IExcelSheet, IExcelRowEnumerator>

An enumerable that yields one T per data row.

Exceptions

ArgumentNullException

sheet is null.

InvalidOperationException

sheet is a table view (AsSheet()) of a table without a header row.

Parse(XlsSheet)

Parses the rows of an XLS sheet into T instances, lazily as the result is enumerated.

public ExcelEnumerable<T, XlsSheet, XlsWorkbook.Enumerator> Parse(XlsSheet sheet)

Parameters

sheet XlsSheet

The sheet to pull rows from. Each enumeration of the result starts a new read of it.

Returns

ExcelEnumerable<T, XlsSheet, XlsWorkbook.Enumerator>

An enumerable that yields one T per data row.

Parse(XlsbSheet)

Parses the rows of an XLSB sheet into T instances, lazily as the result is enumerated.

public ExcelEnumerable<T, XlsbSheet, XlsbWorkbook.Enumerator> Parse(XlsbSheet sheet)

Parameters

sheet XlsbSheet

The sheet to pull rows from. Each enumeration of the result starts a new read of it.

Returns

ExcelEnumerable<T, XlsbSheet, XlsbWorkbook.Enumerator>

An enumerable that yields one T per data row.

Parse(XlsxSheet)

Parses the rows of an XLSX sheet into T instances, lazily as the result is enumerated.

public ExcelEnumerable<T> Parse(XlsxSheet sheet)

Parameters

sheet XlsxSheet

The sheet to pull rows from. Each enumeration of the result starts a new read of it.

Returns

ExcelEnumerable<T>

An enumerable that yields one T per data row.