Parser
omniread.xlsx.parser
Summary
XLSX parser implementations for OmniRead.
This module provides a concrete, generic parser for Office Open XML spreadsheets. It exposes workbook sheets as lists of string rows so downstream consumers can interpret tabular content without depending on openpyxl directly.
The parser is intentionally statement-agnostic: it performs no header detection or column interpretation beyond basic cell normalization.
Classes
XlsxParser
Bases: XlsxParserBase[list[list[str]]]
Generic xlsx parser producing string rows from a worksheet.
Notes
Responsibilities:
1 2 3 4 | |
Constraints:
1 2 3 | |
Initialize the parser.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content |
Content
|
XLSX content to parse; its type must be supported. |
required |
data_only |
bool
|
Passed to openpyxl: when True, formula cells yield their last computed value instead of the formula string. |
True
|
read_only |
bool
|
Passed to openpyxl: streaming mode for lower memory usage. |
True
|
Attributes
supported_types
class-attribute
instance-attribute
Set of content types supported by this parser (XLSX only).
Functions
parse
Parse the first worksheet into normalized string rows.
Returns:
| Type | Description |
|---|---|
list[list[str]]
|
list[list[str]]: Rows of the default (first) worksheet. |
rows
Extract normalized string rows from a worksheet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sheet |
int | str | None
|
Worksheet index or title; defaults to the first worksheet. |
None
|
skip_empty |
bool
|
When True (default), rows whose cells are all blank are omitted. |
True
|
Returns:
| Type | Description |
|---|---|
list[list[str]]
|
list[list[str]]: Normalized rows; trailing blank cells are trimmed per row. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the requested sheet does not exist. |
supports
Check whether this parser supports the content's type.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the content type is supported; False otherwise. |