Table of Contents

Interface IExcelCellConverter<T>

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

Converts a matched cell into a property value. Implement this and attach the implementation with [ExcelConverter(typeof(MyConverter))] for types the built-in parsers do not handle (money strings, custom date formats, domain value objects, ...).

public interface IExcelCellConverter<T>

Type Parameters

T

Remarks

T must be the exact property type (use IExcelCellConverter<T> of decimal? for a decimal? property). A single instance is created once and shared across every row and thread, so implementations must be stateless and thread-safe.

Methods

TryConvert(in Cell, in ExcelRowContext, out T)

Converts a non-empty cell into a value of type T; return false to signal a parse failure, which leaves the target property at its default.

bool TryConvert(in Cell cell, in ExcelRowContext context, out T value)

Parameters

cell Cell

The non-empty cell to convert.

context ExcelRowContext

The date system and format provider to convert with.

value T

The converted value, when this method returns true.

Returns

bool