cadrumo.core.workbook module¶
The workbook-reading policy every layer that opens a spreadsheet shares.
A cell carrying a formula states a computation, not a figure. Beside it a workbook may cache whatever number was last computed into it, and that cached number is not the formula’s value: a sheet edited somewhere else and saved without recalculating carries a figure nobody typed and the formula does not produce. Reading it would take that number as fact.
So a formula cell is refused, never read, everywhere a spreadsheet is treated as a source of financial or filing data — the bank-statement workbook provider, the casilla-value spreadsheet, and the bulk invoice book each refuse on this ground. The alternative, reading the cached value, fails in the direction that matters: the wrong figure reaches a return as a number rather than as any kind of failure, which is the one outcome no downstream check is positioned to catch.
The detection and the sentence live here so the three readers cannot drift apart on what a formula cell is or on what the operator is told about it. What stays with each reader is the part that genuinely differs: which rows are in scope (the statement provider ignores its preamble and header, the other two read every row), and which error type its layer refuses with.
This module deliberately does not import openpyxl. The cell is described
structurally instead, so resolving the policy never pulls a spreadsheet engine
into the innermost layer.
See also
NormalizedTableThe delimited-text counterpart. A workbook states its own cell types, so it has no dialect to detect and shares nothing with that module beyond both being tabular sources.
- FORMULA_CELL_REFUSAL: Final[str]¶
The clause every formula-cell refusal ends with, so all three read alike.
- class WorkbookCell(*args, **kwargs)[source]¶
Bases:
ProtocolThe one attribute the policy needs from a workbook cell.
Structural rather than nominal so that
openpyxl’sCell,ReadOnlyCellandEmptyCellall satisfy it without this module importing the library. Every one of them exposesdata_type.
- first_formula_cell_column(cells)[source]¶
Return the 1-based column of the first formula cell in cells.
- Parameters:
cells (
Iterable[WorkbookCell]) – One row’s cells, in column order.- Return type:
- Returns:
The 1-based column number of the first cell stating a formula, or
Nonewhen the row carries none. Reporting the position rather than raising leaves each caller free to refuse in its own layer’s error type and to name its own artefact, while the test for what counts as a formula stays in one place.