API Reference
ExcelRead
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) #List<T>Type Parameters
- T
Parameters
- path String
- sheetName String
- a1Range String
- options ExcelReadOptions = null
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
- Path to the .xlsx file.
- sheetName System.String
- Worksheet name.
- a1Range System.String
- Single‑column A1 range (e.g., "B2:B100").
- options OfficeIMO.Excel.ExcelReadOptions
- 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
- Path to the .xlsx file.
- sheetIndex System.Int32
- 1‑based sheet index in workbook order.
- a1Range System.String
- Single‑column A1 range (e.g., "B2:B100").
- options OfficeIMO.Excel.ExcelReadOptions
- Optional read options.
Returns
List of typed values.
public static Object[] ReadRange(String path, Int32 sheetIndex, String a1Range, ExcelReadOptions options = null) #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
- Path to the .xlsx file.
- sheetName System.String
- Worksheet name.
- a1Range System.String
- Inclusive A1 range to read.
- options OfficeIMO.Excel.ExcelReadOptions = null
- 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
- Path to the .xlsx file.
- sheetIndex System.Int32
- 1‑based sheet index in workbook order.
- a1Range System.String
- Inclusive A1 range to read.
- options OfficeIMO.Excel.ExcelReadOptions
- 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) #T[]Type Parameters
- T
Parameters
- path String
- sheetName String
- a1Range String
- options ExcelReadOptions = null
public static DataTable ReadRangeAsDataTable(String path, Int32 sheetIndex, String a1Range, Boolean headersInFirstRow = true, ExcelReadOptions options = null) #DataTableReads an A1 range into a DataTable. When headersInFirstRow is true, the first row is used as column names.
Parameters
- path System.String
- Path to the .xlsx file.
- sheetName System.String
- Worksheet name.
- a1Range System.String
- Inclusive A1 range to read.
- headersInFirstRow System.Boolean = true
- Whether to treat the first row as column headers.
- options OfficeIMO.Excel.ExcelReadOptions = null
- 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
- Path to the .xlsx file.
- sheetIndex System.Int32
- 1‑based sheet index in workbook order.
- a1Range System.String
- Inclusive A1 range to read.
- headersInFirstRow System.Boolean
- Whether to treat the first row as column headers.
- options OfficeIMO.Excel.ExcelReadOptions
- Optional read options.
Returns
DataTable containing values from the range.
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
- Path to the .xlsx file.
- sheetName System.String
- Worksheet name.
- a1Range System.String
- Inclusive A1 range to read.
- options OfficeIMO.Excel.ExcelReadOptions
- 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
- Path to the .xlsx file.
- sheetIndex System.Int32
- 1‑based sheet index in workbook order.
- a1Range System.String
- Inclusive A1 range to read.
- options OfficeIMO.Excel.ExcelReadOptions
- 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) #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
- Path to the .xlsx file.
- sheetName System.String
- Worksheet name.
- a1Range System.String
- Inclusive A1 range (first row must contain headers).
- options OfficeIMO.Excel.ExcelReadOptions = null
- Optional read options.
Returns
Materialized list of row dictionaries.
public static List<T> ReadRangeObjectsAs<T>(String path, String sheetName, String a1Range, ExcelReadOptions options = null) #List<T>Type Parameters
- T
Parameters
- path String
- sheetName String
- a1Range String
- options ExcelReadOptions = null
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
- Path to the .xlsx file.
- sheetName System.String
- Worksheet name.
- a1Range System.String
- Inclusive A1 range (first row must contain headers).
- options OfficeIMO.Excel.ExcelReadOptions
- 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) #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
- Path to the .xlsx file.
- a1Range System.String
- Inclusive A1 range (first row must contain headers).
- options OfficeIMO.Excel.ExcelReadOptions = null
- 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) #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
- Path to the .xlsx file.
- sheetNames System.Collections.Generic.IEnumerable{System.String}
- Worksheet names to read.
- a1Range System.String
- Inclusive A1 range (first row must contain headers).
- options OfficeIMO.Excel.ExcelReadOptions = null
- 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) #Object[]Reads the used range of the given sheet into a dense 2D array of typed values.
Parameters
- path System.String
- Path to the .xlsx file.
- sheetName System.String
- Worksheet name containing the data.
- options OfficeIMO.Excel.ExcelReadOptions = null
- 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) #DataTableReads the used range of the given sheet into a DataTable. First row is used as headers when present.
Parameters
- path System.String
- Path to the .xlsx file.
- sheetName System.String
- Worksheet name containing the data.
- headersInFirstRow System.Boolean = true
- Whether to treat the first row as column headers.
- options OfficeIMO.Excel.ExcelReadOptions = null
- Optional read options.
Returns
DataTable containing the values from the sheet's used range.
public static List<Dictionary<String, Object>> ReadUsedRangeObjects(String path, String sheetName, ExcelReadOptions options = null) #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
- Existing ExcelDocument to read from.
- sheetName System.String
- Worksheet name containing the data.
- options OfficeIMO.Excel.ExcelReadOptions = null
- 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
- Path to the .xlsx file.
- sheetName System.String
- Worksheet name containing the data.
- options OfficeIMO.Excel.ExcelReadOptions
- Optional read options controlling type conversion and trimming.
Returns
List of dictionaries representing each row in the sheet's used range.
Inherited Methods
public override Boolean Equals(Object obj) #BooleanParameters
- obj Object