Table of Contents

Class ExcelCellReaders

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

The built-in cell readers ExcelParser<T>'s reflection path already uses, exposed as ExcelCellReader<TValue> instances for a source-generated or hand-written ExcelRowMapBuilder<T> map to plug into Property<TValue>(string[], ExcelCellReader<TValue>, ExcelPropertySetter<T, TValue>, bool, bool) without duplicating the conversion logic.

public static class ExcelCellReaders
Inheritance
ExcelCellReaders
Inherited Members

Fields

Bool

Reads a cell as "1"/"0" or "true"/"false" (case-insensitive).

public static readonly ExcelCellReader<bool> Bool

Field Value

ExcelCellReader<bool>

DateOnlyAuto

Reads a cell as an Excel date serial number, falling back to date-only text when the cell isn't numeric — the DateOnly counterpart of DateTimeAuto, same trade-off.

public static readonly ExcelCellReader<DateOnly> DateOnlyAuto

Field Value

ExcelCellReader<DateOnly>

DateOnlySerial

Reads a cell as an Excel date serial number, truncated to its date component.

public static readonly ExcelCellReader<DateOnly> DateOnlySerial

Field Value

ExcelCellReader<DateOnly>

DateOnlyText

Reads a cell as date-only text rather than a serial number — the only option for CSV.

public static readonly ExcelCellReader<DateOnly> DateOnlyText

Field Value

ExcelCellReader<DateOnly>

DateTimeAuto

Reads a cell as an Excel date/time serial number, falling back to date/time text when the cell isn't numeric. Used where a single map has to work for both a serial-number source (XLSX/XLSB/XLS) and CSV (which has no serial date form and writes ISO text instead) — see Generated<T>(ExcelParserOptions?), which builds one map for every reader. The cost: a CSV cell that is only digits (e.g. an Excel serial typed as plain text) is read as a serial number, not as date text — there is no way to tell those two apart from the cell alone.

public static readonly ExcelCellReader<DateTime> DateTimeAuto

Field Value

ExcelCellReader<DateTime>

DateTimeSerial

Reads a cell as an Excel date/time serial number.

public static readonly ExcelCellReader<DateTime> DateTimeSerial

Field Value

ExcelCellReader<DateTime>

DateTimeText

Reads a cell as date/time text (ISO or culture format) rather than a serial number — the only option for CSV, which has no serial date form.

public static readonly ExcelCellReader<DateTime> DateTimeText

Field Value

ExcelCellReader<DateTime>

String

Reads a cell as text.

[SuppressMessage("Naming", "CA1720:Identifier contains type name", Justification = "Matches the property type it reads, mirroring the other members of this class (Bool, DateTimeSerial, ...).")]
public static readonly ExcelCellReader<string> String

Field Value

ExcelCellReader<string>

TimeOnlyAuto

Reads a cell as an Excel time-of-day serial number, falling back to time-only text when the cell isn't numeric — the TimeOnly counterpart of DateTimeAuto, same trade-off.

public static readonly ExcelCellReader<TimeOnly> TimeOnlyAuto

Field Value

ExcelCellReader<TimeOnly>

TimeOnlySerial

Reads a cell as an Excel time-of-day serial number (the fractional part of a day).

public static readonly ExcelCellReader<TimeOnly> TimeOnlySerial

Field Value

ExcelCellReader<TimeOnly>

TimeOnlyText

Reads a cell as time-only text rather than a serial number — the only option for CSV.

public static readonly ExcelCellReader<TimeOnly> TimeOnlyText

Field Value

ExcelCellReader<TimeOnly>

Methods

Enum<TEnum>(in Cell, in ExcelRowContext, out TEnum)

Reads a cell as an enum, by its declared value name (case-insensitive) or its underlying numeric value.

public static bool Enum<TEnum>(in Cell cell, in ExcelRowContext context, out TEnum value) where TEnum : struct, Enum

Parameters

cell Cell
context ExcelRowContext
value TEnum

Returns

bool

Type Parameters

TEnum

The enum type to parse.

Parsable<TValue>(in Cell, in ExcelRowContext, out TValue)

Reads a cell as any type TryParse<T>(IFormatProvider?, out T) supports: every integral type, float/double/decimal, and Guid.

public static bool Parsable<TValue>(in Cell cell, in ExcelRowContext context, out TValue value) where TValue : IUtf8SpanParsable<TValue>

Parameters

cell Cell
context ExcelRowContext
value TValue

Returns

bool

Type Parameters

TValue

The value type to parse.

SpanParsable<TValue>(in Cell, in ExcelRowContext, out TValue)

Reads a cell by decoding its text and calling TryParse(ReadOnlySpan<char>, IFormatProvider, out TSelf), for types such as TimeSpan and DateTimeOffset that have no UTF-8 parser.

public static bool SpanParsable<TValue>(in Cell cell, in ExcelRowContext context, out TValue value) where TValue : ISpanParsable<TValue>

Parameters

cell Cell
context ExcelRowContext
value TValue

Returns

bool

Type Parameters

TValue

The value type to parse.

Utf8(scoped in Cell, scoped in ExcelRowContext, out ReadOnlySpan<byte>)

Reads a cell's raw UTF-8 bytes without allocating. The span aliases the reader's buffer and is valid only until the reader advances.

public static bool Utf8(scoped in Cell cell, scoped in ExcelRowContext context, out ReadOnlySpan<byte> value)

Parameters

cell Cell
context ExcelRowContext
value ReadOnlySpan<byte>

Returns

bool