Class ExcelContext
ExcelContext exposes a lazy, query-oriented view over an XLSX workbook.
- Sheets are accessible by index via the
sheetslist, each as aSheetContext. - Sheets are also accessible by name at the root level, resolving to their default table (first row = headers).
- Cells on a sheet can be queried using A1 notation via
sheet.get("A1"). - A sheet's default table is available via the special key
"rows"on aSheetContext. - Named tables, when present, are exposed at the root level by their table name, each as a list of records mapping header names to row values.
The underlying XLSX data is accessed lazily: no pre-loading of all sheets occurs in the constructor; data is read only when a property is actually queried.
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> -
Method Summary
Modifier and TypeMethodDescriptionentrySet()static ExcelContextfrom(InputStream inputStream) Create a new context from an input stream containing an.xlsxfile.static ExcelContextCreate a new context from a path to an.xlsxfile.static ExcelContextfrom(org.docx4j.openpackaging.packages.SpreadsheetMLPackage spreadsheet) Create a new context from a SpreadsheetMLPackage.joinAllSheets(String joinKey) Merges all sheets in the workbook into a single list of records using an inner join.Methods inherited from class AbstractMap
clear, clone, containsKey, containsValue, equals, hashCode, isEmpty, keySet, put, putAll, remove, size, toString, valuesMethods inherited from interface Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Method Details
-
from
Create a new context from a SpreadsheetMLPackage.- Parameters:
spreadsheet- SpreadsheetMLPackage to use- Returns:
- a new
ExcelContextinstance
-
from
Create a new context from a path to an.xlsxfile.- Parameters:
path- Path to the Excel workbook file- Returns:
- a new
ExcelContextinstance - Throws:
ExcelException- if the file cannot be read
-
from
Create a new context from an input stream containing an
.xlsxfile.The input stream is consumed during construction.
- Parameters:
inputStream- Input stream of an Excel workbook- Returns:
- a new
ExcelContextinstance - Throws:
ExcelException- if the stream cannot be parsed
-
joinAllSheets
-
get
-
entrySet
-