Class ExcelParser<T>
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
TThe model type to bind each row to. May be a
ref struct, including one with aReadOnlySpan<byte>property. Astruct Tconsumed via a directforeachskips the per-row model allocation a classTrequires.
- 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
sheetCsvSheetThe CSV sheet to pull records from.
Returns
- CsvEnumerable<T>
An enumerable that yields one
Tper 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
sheetIExcelSheetThe 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
Tper data row.
Exceptions
- ArgumentNullException
sheetis null.- InvalidOperationException
sheetis 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
sheetXlsSheetThe 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
Tper 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
sheetXlsbSheetThe 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
Tper 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
sheetXlsxSheetThe sheet to pull rows from. Each enumeration of the result starts a new read of it.
Returns
- ExcelEnumerable<T>
An enumerable that yields one
Tper data row.