01 / Reproduce
Run the workbook cache lab
Download the practice ZIP below and extract its three files into a fresh folder: check_cache.py, requirements.txt and README.md. Use Python 3.10 or later. Open PowerShell in that folder and run:
py -3 -m venv .venv
.\.venv\Scripts\python.exe -m pip install -r requirements.txt
.\.venv\Scripts\python.exe .\check_cache.py create demo
.\.venv\Scripts\python.exe .\check_cache.py inspect .\demo\missing-cache.xlsx
.\.venv\Scripts\python.exe .\check_cache.py inspect .\demo\authored-cache.xlsx
The requirements pin openpyxl 3.1.5, et-xmlfile 2.0.0 and defusedxml 0.7.1. Installation needs internet access; the exercise then runs on fictional local files without an account, AI API, model download or Excel installation. The script refuses to create demo if that directory already exists. Use a new directory name for another run.
The create command writes two workbooks. Both contain 2 in A1, 3 in A2, =SUM(A1:A2) in A3, literal 0 in B1 and an empty B2 on the Demo sheet. The first has no cached formula answer. The second contains an explicitly authored cache of 999, inserted into the XLSX XML by the exercise. Excel did not calculate it.
The inspect command prints JSON with a file hash and five cell records. These are the observed A3 records, abbreviated from those two reports:
missing-cache.xlsx / Demo!A3
formula: =SUM(A1:A2)
value: null
status: formula_cache_missing
authored-cache.xlsx / Demo!A3
formula: =SUM(A1:A2)
value: 999
status: formula_cache_unverified
Both files / Demo!B1: value 0, literal_value
Both files / Demo!B2: value null, ordinary_blank
JSON null represents Python's None. It is not the number zero. The simple independent arithmetic 2 + 3 gives 5, which exposes the authored 999 as inconsistent with these inputs. The inspector itself does not evaluate the workbook formula.
02 / Inspect
Inspect the formula and cache
An XLSX formula cell can carry an expression and a stored result. openpyxl's load_workbook documentation distinguishes the default formula view from data_only=True, which reads the stored value. Switching the flag does not request a new calculation.
In inspect, both workbook views consume the same byte snapshot. That keeps this comparison tied to one version of the file:
before = path.read_bytes()
# Both views consume the exact same immutable bytes, even if a path changes.
formulas = load_workbook(io.BytesIO(before), read_only=True, data_only=False, keep_links=False)
values = None
try:
values = load_workbook(io.BytesIO(before), read_only=True, data_only=True, keep_links=False)
This excerpt begins the function's try block; use the complete script for iteration and resource cleanup. The script reads five fixed cells on the Demo sheet, closes both workbook views in finally and never calls save during inspection.
For each selected cell, it checks the formula view's type and the value view separately:
is_formula = source.data_type == "f"
if is_formula:
status = "formula_cache_missing" if cached is None else "formula_cache_unverified"
else:
status = "ordinary_blank" if source.value is None else "literal_value"
The comparison is is None, so a literal zero survives. A missing cached result and an ordinary blank receive different labels because the first view still reveals whether a formula exists. The label formula_cache_unverified deliberately makes no freshness claim.
The project's formula guide states that openpyxl does not evaluate formulas. A formula string is therefore evidence of an expression stored in a cell, not evidence that this library calculated its answer.
03 / Adapt
Make it your own
Change the two fictional inputs while keeping the same formula. Run in the extracted practice folder:
.\.venv\Scripts\python.exe .\check_cache.py create demo-15 --left 7 --right 8
.\.venv\Scripts\python.exe .\check_cache.py inspect .\demo-15\missing-cache.xlsx
.\.venv\Scripts\python.exe .\check_cache.py inspect .\demo-15\authored-cache.xlsx
We checked this adaptation: A1 and A2 become 7 and 8; A3 still contains =SUM(A1:A2). The missing cache stays missing and the authored cache stays 999. Independent arithmetic gives 15. Changing inputs through this exercise does not turn openpyxl into a calculation engine.
For an AI-assisted reporting workflow you control, make a small extraction manifest before generating a narrative. Retain the workbook version or hash, sheet, cell address, formula, extracted value and cache status. A hash identifies the bytes you inspected; it does not establish who created them. Hold unresolved formula results for review rather than converting them to zero.
If a result is needed, use a spreadsheet application or compatible calculation engine to calculate and save a separate copy, then inspect that copy and independently check important outputs. Choose a tool that supports the workbook's actual functions and connections. We did not execute that recalculation step or test Excel behavior in this run. A present cache alone remains insufficient evidence of currency.
Here is a proposed review prompt to use only with an approved, appropriately redacted manifest. It has not been run against a model:
Summarize only the verified values in this extraction manifest.
List unresolved formula-cache cells separately, with sheet and address.
Do not replace missing values with zero or calculate arbitrary formulas.
Mark unverified cached values as needing review.
Separate source evidence from any interpretation.
Enforce those decisions in the extraction and review process as well. A prompt request does not prove that a model will follow it.
04 / Evidence
Keep the evidence in scope
We ran the commands on the fictional files and repeated the workflow from the extracted practice ZIP. Missing and authored caches, literal zero, ordinary blank, changed inputs, JSON records, source-byte preservation and refusal to overwrite an existing exercise folder passed. Inspection reads a fixed five-cell range; this is not an audit of every cell in a workbook.
The 999 fixture demonstrates reading an authored cache. It is not an observed Excel failure, stale production report or model hallucination. No AI summary, spreadsheet recalculation, complex or array formula, macro, external reference, spreadsheet error, financial decision, performance benchmark or untrusted-file security audit was tested.
Keep originals unchanged. The openpyxl tutorial warns that saving can overwrite files and that some workbook features may be lost. This kit uses read-only views for inspection and does not save the inspected workbook. The PyPI project also documents XML parsing considerations; the pinned environment includes defusedxml, but these fictional examples do not establish safe handling of arbitrary files.
05 / Sources
Read the primary sources
Checked November 28, 2026. The published stable documentation labels itself 3.1.3; our installed and exercised package is pinned to 3.1.5. These are established library behaviors, not a newly announced AI feature.
- openpyxl: workbook reader API — formula and data-only reading modes.
- openpyxl: using formulas — writing expressions without evaluating them.
- openpyxl: tutorial — workbook access, saving and preservation limitations.
- PyPI: openpyxl 3.1.5 — release metadata and project XML parsing notes.
06 / Take it with you
Get the practice and posting files
The practice ZIP contains the script, pinned requirements and instructions; its create command generates both fictional workbooks locally. The posting ZIP contains the original graphic, teaser, alt text and canonical article URL. Social content is prepared for manual posting; it is not scheduled or published.

