API Reference

Class

ExcelDocumentReader

Namespace OfficeIMO.Excel
Assembly OfficeIMO.Excel
Implements
IDisposable
Modifiers sealed

Reader for an Excel workbook (read-only). Provides access to sheet readers and basic metadata.

Inheritance

  • Object
  • ExcelDocumentReader

Usage

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Accepted by parameters

Methods

public virtual Void Dispose() #
Returns: Void

Disposes the underlying OpenXML document.

GetSheet 2 overloads
public ExcelSheetReader GetSheet(String name) #
Returns: ExcelSheetReader

Gets a reader for the specified worksheet name.

Parameters

name System.String requiredposition: 0
public ExcelSheetReader GetSheet(Int32 index) #
Returns: ExcelSheetReader

Gets a reader by sheet index (1-based, Excel display order).

Parameters

index System.Int32 requiredposition: 0
public IReadOnlyList<String> GetSheetNames() #
Returns: IReadOnlyList<String>

Returns the list of sheet names in workbook order.

public ExcelTableInfo GetTable(String tableName) #
Returns: ExcelTableInfo

Gets metadata for a table by name or display name.

Parameters

tableName System.String requiredposition: 0
public IReadOnlyList<ExcelTableInfo> GetTables() #
Returns: IReadOnlyList<ExcelTableInfo>

Returns all Excel tables defined in the workbook.

Open 4 overloads
public static ExcelDocumentReader Open(Byte[] bytes, ExcelReadOptions options = null) #
Returns: ExcelDocumentReader

Opens an Excel file for read-only access.

Parameters

path System.String requiredposition: 0
options OfficeIMO.Excel.ExcelReadOptions = null optionalposition: 1
Open(System.IO.Stream stream, OfficeIMO.Excel.ExcelReadOptions options) #

Opens an Excel workbook from the provided stream for read-only access.

Parameters

stream System.IO.Stream required
options OfficeIMO.Excel.ExcelReadOptions required
Open(System.Byte[] bytes, OfficeIMO.Excel.ExcelReadOptions options) #

Opens an Excel workbook from an in-memory package for read-only access. The byte array is used directly; callers should not modify it while the reader is alive.

Parameters

bytes System.Byte[] required
options OfficeIMO.Excel.ExcelReadOptions required
public static ExcelDocumentReader Open(Uri uri, ExcelReadOptions options = null, ExcelHttpLoadOptions httpOptions = null) #
Returns: ExcelDocumentReader

Opens a remote Excel workbook for read-only access.

Parameters

uri System.Uri requiredposition: 0
HTTP or HTTPS URI of the workbook.
options OfficeIMO.Excel.ExcelReadOptions = null optionalposition: 1
Optional read options.
httpOptions OfficeIMO.Excel.ExcelHttpLoadOptions = null optionalposition: 2
Optional HTTP loading options.

Returns

Workbook reader.

public static async Task<ExcelDocumentReader> OpenAsync(Uri uri, ExcelReadOptions options = null, ExcelHttpLoadOptions httpOptions = null, CancellationToken cancellationToken = null) #
Returns: Task<ExcelDocumentReader>

Asynchronously opens a remote Excel workbook for read-only access.

Parameters

uri System.Uri requiredposition: 0
HTTP or HTTPS URI of the workbook.
options OfficeIMO.Excel.ExcelReadOptions = null optionalposition: 1
Optional read options.
httpOptions OfficeIMO.Excel.ExcelHttpLoadOptions = null optionalposition: 2
Optional HTTP loading options.
cancellationToken System.Threading.CancellationToken = null optionalposition: 3
Cancellation token.

Returns

Workbook reader.

public Object[] ReadTable(String tableName) #
Returns: Object[]

Reads an Excel table by name into a dense matrix.

Parameters

tableName System.String requiredposition: 0
public DataTable ReadTableAsDataTable(String tableName, Nullable<Boolean> headersInFirstRow = null, Nullable<ExecutionMode> mode = null, CancellationToken ct = null) #
Returns: DataTable

Reads an Excel table by name into a DataTable.

Parameters

tableName System.String requiredposition: 0
headersInFirstRow System.Nullable{System.Boolean} = null optionalposition: 1
mode System.Nullable{OfficeIMO.Excel.ExecutionMode} = null optionalposition: 2
ct System.Threading.CancellationToken = null optionalposition: 3
public IEnumerable<T> ReadTableObjects<T>(String tableName, Nullable<ExecutionMode> mode = null, CancellationToken ct = null) #
Returns: IEnumerable<T>

Reads an Excel table by name as dictionaries using the table header row.

Type Parameters

T

Parameters

tableName System.String requiredposition: 0
mode System.Nullable{OfficeIMO.Excel.ExecutionMode} = null optionalposition: 1
ct System.Threading.CancellationToken = null optionalposition: 2
public IEnumerable<T> ReadTableObjectsStream<T>(String tableName, CancellationToken ct = null) #
Returns: IEnumerable<T>

Type Parameters

T

Parameters

tableName String requiredposition: 0
ct CancellationToken = null optionalposition: 1
ReadTableObjectsStream``1(System.String tableName, System.Threading.CancellationToken ct) #

Streams an Excel table by name and maps rows to objects using the table header row.

Parameters

tableName System.String required
ct System.Threading.CancellationToken required
ReadTableObjects``1(System.String tableName, System.Nullable{OfficeIMO.Excel.ExecutionMode} mode, System.Threading.CancellationToken ct) #

Reads an Excel table by name and maps rows to objects using the table header row.

Parameters

tableName System.String required
mode System.Nullable{OfficeIMO.Excel.ExecutionMode} required
ct System.Threading.CancellationToken required
public static ExcelDocumentReader Wrap(SpreadsheetDocument document, ExcelReadOptions options = null) #
Returns: ExcelDocumentReader

Wraps an already open SpreadsheetDocument without taking ownership. The returned reader must be disposed, but it will not close the underlying document.

Parameters

document DocumentFormat.OpenXml.Packaging.SpreadsheetDocument requiredposition: 0
options OfficeIMO.Excel.ExcelReadOptions = null optionalposition: 1

Properties

public Int32 SheetCount { get; } #

The number of worksheets in the workbook.

Extension Methods

public static IEnumerable<ExcelExtractChunk> ExtractChunks(ExcelDocumentReader reader, String sheetName, String a1Range = null, ExcelExtractOptions extract = null, ExcelExtractChunkingOptions chunking = null, String sourcePath = null, CancellationToken cancellationToken = null) #
Returns: IEnumerable<ExcelExtractChunk>

Extracts an Excel sheet range into row-chunked ExcelExtractChunk instances.

Parameters

reader OfficeIMO.Excel.ExcelDocumentReader requiredposition: 0
Workbook reader.
sheetName System.String requiredposition: 1
Sheet to extract.
a1Range System.String = null optionalposition: 2
A1 range; when null, uses the sheet's used range.
extract OfficeIMO.Excel.ExcelExtractionExtensions.ExcelExtractOptions = null optionalposition: 3
Extraction options.
chunking OfficeIMO.Excel.ExcelExtractChunkingOptions = null optionalposition: 4
Chunking options.
sourcePath System.String = null optionalposition: 5
Optional source path for citations.
cancellationToken System.Threading.CancellationToken = null optionalposition: 6
Cancellation token.