OfficeIMO

API Reference

Class

ExcelRead

Namespace OfficeIMO.Excel
Assembly OfficeIMO.Excel
Modifiers static

Static helpers for quick one‑liner read operations. These helpers open the workbook read‑only, materialize the requested result, and then dispose it. Use these when you prefer brevity over streaming/iterator patterns.

Inheritance

  • Object
  • ExcelRead

Methods

public static List<T> ReadColumnAs<T>(String path, Int32 sheetIndex, String a1Range, ExcelReadOptions options = null) #
Returns: List<T>

Type Parameters

T

Parameters

path String requiredposition: 0
sheetName String requiredposition: 1
a1Range String requiredposition: 2
options ExcelReadOptions = null optionalposition: 3
ReadColumnAs``1 2 overloads
ReadColumnAs``1(System.String path, System.String sheetName, System.String a1Range, OfficeIMO.Excel.ExcelReadOptions options) #

Reads a single‑column A1 range as a typed sequence and materializes it into a list.

Type Parameters

T
Target element type.

Parameters

path System.String required
Path to the .xlsx file.
sheetName System.String required
Worksheet name.
a1Range System.String required
Single‑column A1 range (e.g., "B2:B100").
options OfficeIMO.Excel.ExcelReadOptions required
Optional read options.

Returns

List of typed values.

ReadColumnAs``1(System.String path, System.Int32 sheetIndex, System.String a1Range, OfficeIMO.Excel.ExcelReadOptions options) #

Reads a single‑column A1 range as a typed list by sheet index (1‑based).

Type Parameters

T
Target element type.

Parameters

path System.String required
Path to the .xlsx file.
sheetIndex System.Int32 required
1‑based sheet index in workbook order.
a1Range System.String required
Single‑column A1 range (e.g., "B2:B100").
options OfficeIMO.Excel.ExcelReadOptions required
Optional read options.

Returns

List of typed values.

ReadRange 2 overloads
public static Object[] ReadRange(String path, Int32 sheetIndex, String a1Range, ExcelReadOptions options = null) #
Returns: Object[]

Reads a rectangular A1 range (e.g., "A1:C10") from the specified sheet into a dense 2D array of typed values.

Parameters

path System.String requiredposition: 0
Path to the .xlsx file.
sheetName System.String requiredposition: 1
Worksheet name.
a1Range System.String requiredposition: 2
Inclusive A1 range to read.
options OfficeIMO.Excel.ExcelReadOptions = null optionalposition: 3
Optional read options (presets are available in ExcelReadPresets).

Returns

Typed matrix with nulls for blank cells.

ReadRange(System.String path, System.Int32 sheetIndex, System.String a1Range, OfficeIMO.Excel.ExcelReadOptions options) #

Reads an A1 range into a dense 2D array of typed values by sheet index (1‑based).

Parameters

path System.String required
Path to the .xlsx file.
sheetIndex System.Int32 required
1‑based sheet index in workbook order.
a1Range System.String required
Inclusive A1 range to read.
options OfficeIMO.Excel.ExcelReadOptions required
Optional read options.

Returns

Typed matrix with nulls for blank cells.

public static T[] ReadRangeAs<T>(String path, Int32 sheetIndex, String a1Range, ExcelReadOptions options = null) #
Returns: T[]

Type Parameters

T

Parameters

path String requiredposition: 0
sheetName String requiredposition: 1
a1Range String requiredposition: 2
options ExcelReadOptions = null optionalposition: 3
ReadRangeAsDataTable 2 overloads
public static DataTable ReadRangeAsDataTable(String path, Int32 sheetIndex, String a1Range, Boolean headersInFirstRow = true, ExcelReadOptions options = null) #
Returns: DataTable

Reads an A1 range into a DataTable. When headersInFirstRow is true, the first row is used as column names.

Parameters

path System.String requiredposition: 0
Path to the .xlsx file.
sheetName System.String requiredposition: 1
Worksheet name.
a1Range System.String requiredposition: 2
Inclusive A1 range to read.
headersInFirstRow System.Boolean = true optionalposition: 3
Whether to treat the first row as column headers.
options OfficeIMO.Excel.ExcelReadOptions = null optionalposition: 4
Optional read options.

Returns

DataTable containing values from the range.

ReadRangeAsDataTable(System.String path, System.Int32 sheetIndex, System.String a1Range, System.Boolean headersInFirstRow, OfficeIMO.Excel.ExcelReadOptions options) #

Reads an A1 range into a DataTable by sheet index (1‑based).

Parameters

path System.String required
Path to the .xlsx file.
sheetIndex System.Int32 required
1‑based sheet index in workbook order.
a1Range System.String required
Inclusive A1 range to read.
headersInFirstRow System.Boolean required
Whether to treat the first row as column headers.
options OfficeIMO.Excel.ExcelReadOptions required
Optional read options.

Returns

DataTable containing values from the range.

ReadRangeAs``1 2 overloads
ReadRangeAs``1(System.String path, System.String sheetName, System.String a1Range, OfficeIMO.Excel.ExcelReadOptions options) #

Reads an A1 range into a dense typed matrix.

Type Parameters

T
Element type for each cell in the matrix.

Parameters

path System.String required
Path to the .xlsx file.
sheetName System.String required
Worksheet name.
a1Range System.String required
Inclusive A1 range to read.
options OfficeIMO.Excel.ExcelReadOptions required
Optional read options.

Returns

Typed matrix populated from the requested range.

ReadRangeAs``1(System.String path, System.Int32 sheetIndex, System.String a1Range, OfficeIMO.Excel.ExcelReadOptions options) #

Reads an A1 range into a dense typed matrix by sheet index (1‑based).

Type Parameters

T
Element type for each cell in the matrix.

Parameters

path System.String required
Path to the .xlsx file.
sheetIndex System.Int32 required
1‑based sheet index in workbook order.
a1Range System.String required
Inclusive A1 range to read.
options OfficeIMO.Excel.ExcelReadOptions required
Optional read options.

Returns

Typed matrix populated from the requested range.

public static List<Dictionary<String, Object>> ReadRangeObjects(String path, String sheetName, String a1Range, ExcelReadOptions options = null) #
Returns: List<Dictionary<String, Object>>

Reads an A1 range as a sequence of dictionaries using the first row as headers. Keys are header names (case-insensitive in the reader), values are typed when possible.

Parameters

path System.String requiredposition: 0
Path to the .xlsx file.
sheetName System.String requiredposition: 1
Worksheet name.
a1Range System.String requiredposition: 2
Inclusive A1 range (first row must contain headers).
options OfficeIMO.Excel.ExcelReadOptions = null optionalposition: 3
Optional read options.

Returns

Materialized list of row dictionaries.

public static List<T> ReadRangeObjectsAs<T>(String path, String sheetName, String a1Range, ExcelReadOptions options = null) #
Returns: List<T>

Type Parameters

T

Parameters

path String requiredposition: 0
sheetName String requiredposition: 1
a1Range String requiredposition: 2
options ExcelReadOptions = null optionalposition: 3
ReadRangeObjectsAs``1(System.String path, System.String sheetName, System.String a1Range, OfficeIMO.Excel.ExcelReadOptions options) #

Reads an A1 range and maps rows (excluding the header row) to instances of T. Header cells are matched to public writable properties on T by name (case‑insensitive).

Type Parameters

T
Target type whose writable properties receive the row values.

Parameters

path System.String required
Path to the .xlsx file.
sheetName System.String required
Worksheet name.
a1Range System.String required
Inclusive A1 range (first row must contain headers).
options OfficeIMO.Excel.ExcelReadOptions required
Optional read options.

Returns

List of T populated from each data row.

public static Dictionary<String, List<Dictionary<String, Object>>> ReadRangeObjectsFromAllSheets(String path, String a1Range, ExcelReadOptions options = null) #
Returns: Dictionary<String, List<Dictionary<String, Object>>>

Reads an A1 range from every sheet in the workbook as dictionaries using the first row as headers.

Parameters

path System.String requiredposition: 0
Path to the .xlsx file.
a1Range System.String requiredposition: 1
Inclusive A1 range (first row must contain headers).
options OfficeIMO.Excel.ExcelReadOptions = null optionalposition: 2
Optional read options.

Returns

Dictionary mapping each sheet name to the list of row dictionaries read from that sheet.

public static Dictionary<String, List<Dictionary<String, Object>>> ReadRangeObjectsFromSheets(String path, IEnumerable<String> sheetNames, String a1Range, ExcelReadOptions options = null) #
Returns: Dictionary<String, List<Dictionary<String, Object>>>

Reads an A1 range from multiple sheets as dictionaries using the first row as headers.

Parameters

path System.String requiredposition: 0
Path to the .xlsx file.
sheetNames System.Collections.Generic.IEnumerable{System.String} requiredposition: 1
Worksheet names to read.
a1Range System.String requiredposition: 2
Inclusive A1 range (first row must contain headers).
options OfficeIMO.Excel.ExcelReadOptions = null optionalposition: 3
Optional read options.

Returns

Dictionary mapping each sheet name to the list of row dictionaries read from that sheet.

public static Object[] ReadUsedRange(String path, String sheetName, ExcelReadOptions options = null) #
Returns: Object[]

Reads the used range of the given sheet into a dense 2D array of typed values.

Parameters

path System.String requiredposition: 0
Path to the .xlsx file.
sheetName System.String requiredposition: 1
Worksheet name containing the data.
options OfficeIMO.Excel.ExcelReadOptions = null optionalposition: 2
Optional read options.

Returns

Typed matrix populated from the used range.

public static DataTable ReadUsedRangeAsDataTable(String path, String sheetName, Boolean headersInFirstRow = true, ExcelReadOptions options = null) #
Returns: DataTable

Reads the used range of the given sheet into a DataTable. First row is used as headers when present.

Parameters

path System.String requiredposition: 0
Path to the .xlsx file.
sheetName System.String requiredposition: 1
Worksheet name containing the data.
headersInFirstRow System.Boolean = true optionalposition: 2
Whether to treat the first row as column headers.
options OfficeIMO.Excel.ExcelReadOptions = null optionalposition: 3
Optional read options.

Returns

DataTable containing the values from the sheet's used range.

ReadUsedRangeObjects 2 overloads
public static List<Dictionary<String, Object>> ReadUsedRangeObjects(String path, String sheetName, ExcelReadOptions options = null) #
Returns: List<Dictionary<String, Object>>

Reads the used range of a sheet as dictionaries (first row as headers) using an already-open ExcelDocument. Avoids re-opening the file and potential file locks.

Parameters

doc OfficeIMO.Excel.ExcelDocument requiredposition: 0
Existing ExcelDocument to read from.
sheetName System.String requiredposition: 1
Worksheet name containing the data.
options OfficeIMO.Excel.ExcelReadOptions = null optionalposition: 2
Optional read options controlling type conversion and trimming.

Returns

List of dictionaries representing each row in the sheet's used range.

ReadUsedRangeObjects(System.String path, System.String sheetName, OfficeIMO.Excel.ExcelReadOptions options) #

Reads the used range of a sheet as dictionaries (first row as headers).

Parameters

path System.String required
Path to the .xlsx file.
sheetName System.String required
Worksheet name containing the data.
options OfficeIMO.Excel.ExcelReadOptions required
Optional read options controlling type conversion and trimming.

Returns

List of dictionaries representing each row in the sheet's used range.