cellproof 0.2.2__tar.gz → 0.3.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cellproof-0.2.2 → cellproof-0.3.1}/AGENTS.md +2 -1
- cellproof-0.3.1/CHANGELOG.md +94 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/PKG-INFO +38 -16
- {cellproof-0.2.2 → cellproof-0.3.1}/PROGRESS.md +20 -5
- {cellproof-0.2.2 → cellproof-0.3.1}/README.md +37 -15
- {cellproof-0.2.2 → cellproof-0.3.1}/pyproject.toml +1 -1
- cellproof-0.3.1/src/cellproof/__init__.py +1 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/src/cellproof/cli.py +2 -1
- {cellproof-0.2.2 → cellproof-0.3.1}/src/cellproof/compiler.py +19 -5
- {cellproof-0.2.2 → cellproof-0.3.1}/src/cellproof/expr.py +9 -1
- {cellproof-0.2.2 → cellproof-0.3.1}/src/cellproof/fn/__init__.py +1 -1
- cellproof-0.3.1/src/cellproof/fn/aggregate.py +473 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/src/cellproof/fn/dates.py +64 -2
- cellproof-0.3.1/src/cellproof/fn/finance.py +103 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/src/cellproof/fn/logic.py +47 -4
- {cellproof-0.2.2 → cellproof-0.3.1}/src/cellproof/fn/lookup.py +141 -19
- cellproof-0.3.1/src/cellproof/fn/stats.py +116 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/src/cellproof/functions.py +2 -13
- {cellproof-0.2.2 → cellproof-0.3.1}/src/cellproof/graph.py +2 -0
- cellproof-0.3.1/src/cellproof/impact.py +57 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/src/cellproof/model.py +10 -1
- {cellproof-0.2.2 → cellproof-0.3.1}/src/cellproof/parser.py +2 -1
- {cellproof-0.2.2 → cellproof-0.3.1}/src/cellproof/reader.py +31 -5
- {cellproof-0.2.2 → cellproof-0.3.1}/src/cellproof/region.py +1 -1
- {cellproof-0.2.2 → cellproof-0.3.1}/src/cellproof/report.py +18 -2
- cellproof-0.3.1/src/cellproof/tables.py +162 -0
- cellproof-0.3.1/tests/test_arrays.py +166 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/tests/test_corpus_findings.py +35 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/tests/test_excel_findings.py +8 -6
- cellproof-0.3.1/tests/test_finance_stats.py +135 -0
- cellproof-0.3.1/tests/test_impact.py +115 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/tests/test_implicit.py +6 -5
- {cellproof-0.2.2 → cellproof-0.3.1}/tests/test_logic.py +36 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/tests/test_lookup.py +2 -2
- cellproof-0.3.1/tests/test_lookups.py +136 -0
- cellproof-0.3.1/tests/test_tables.py +75 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/tests/xlsxkit.py +40 -8
- cellproof-0.2.2/CHANGELOG.md +0 -50
- cellproof-0.2.2/src/cellproof/__init__.py +0 -1
- cellproof-0.2.2/src/cellproof/fn/aggregate.py +0 -197
- cellproof-0.2.2/tests/test_arrays.py +0 -45
- cellproof-0.2.2/tests/test_lookups.py +0 -49
- {cellproof-0.2.2 → cellproof-0.3.1}/.github/workflows/ci.yml +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/.github/workflows/publish.yml +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/.gitignore +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/DESIGN.md +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/INFO.md +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/LICENSE +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/PLAN-2a.md +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/PLAN-2b.md +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/PLAN.md +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/SECURITY.md +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/docs/JOURNEY.md +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/docs/superpowers/plans/2026-10-14-plan-2c-speed.md +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/docs/superpowers/plans/2026-10-14-plan-2d-table-mode.md +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/docs/superpowers/specs/2026-10-14-plan-2c-speed-design.md +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/docs/superpowers/specs/2026-10-14-plan-2d-table-mode-design.md +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/docs/superpowers/specs/2026-10-18-running-totals-design.md +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/docs/superpowers/specs/2026-10-19-lookups-row-wise-design.md +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/examples/commission.xlsx +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/examples/errors.xlsx +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/examples/functions.xlsx +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/examples/functions_unsaved.xlsx +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/examples/make_commission.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/examples/make_errors.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/examples/make_functions.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/src/cellproof/__main__.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/src/cellproof/compute.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/src/cellproof/emitter.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/src/cellproof/fenwick.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/src/cellproof/fn/criteria.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/src/cellproof/fn/maths.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/src/cellproof/fn/text.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/src/cellproof/r1c1.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/src/cellproof/rangeindex.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/src/cellproof/refs.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/src/cellproof/regions.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/src/cellproof/verifier.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/tests/bench_shapes.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/tests/corpus.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/tests/test_aggregate.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/tests/test_batches.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/tests/test_cli.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/tests/test_compiler.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/tests/test_compute.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/tests/test_criteria.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/tests/test_dates.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/tests/test_emitter.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/tests/test_errors.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/tests/test_excel_saved.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/tests/test_fenwick.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/tests/test_functions.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/tests/test_graph.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/tests/test_index.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/tests/test_lexed.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/tests/test_limits.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/tests/test_maths.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/tests/test_parser.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/tests/test_perf.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/tests/test_r1c1.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/tests/test_rangeindex.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/tests/test_reader.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/tests/test_refs.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/tests/test_region.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/tests/test_regions.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/tests/test_regions_differential.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/tests/test_regions_split.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/tests/test_report.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/tests/test_review_regressions.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/tests/test_running.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/tests/test_shapes.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/tests/test_text.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/tests/test_types.py +0 -0
- {cellproof-0.2.2 → cellproof-0.3.1}/tests/test_verifier.py +0 -0
|
@@ -28,7 +28,8 @@ CELLPROOF_PERF=1 python -m pytest tests/test_perf.py -s # 200k-formula benchmar
|
|
|
28
28
|
| `expr.py` | `Expr` (SQL value + SQL error code), Excel coercions |
|
|
29
29
|
| `compiler.py` | cell mode: formula -> SQL in batches |
|
|
30
30
|
| `region.py` | a region -> one set-based statement (window functions for running totals) |
|
|
31
|
-
| `functions.py`, `fn/` | the
|
|
31
|
+
| `functions.py`, `fn/` | the 121 Excel functions (`fn/finance.py`, `fn/stats.py` new in 0.3.0; LET in `fn/logic.py`) |
|
|
32
|
+
| `tables.py` | structured references to Excel tables -> A1 text, applied by the reader |
|
|
32
33
|
| `verifier.py` | runs everything on DuckDB and compares with Excel's saved values |
|
|
33
34
|
| `emitter.py` | writes the dbt project; `--dbt` runs `dbt build` |
|
|
34
35
|
| `report.py`, `cli.py`, `compute.py` | REPORT.md/report.json, the CLI, the optional `formulas` answer key |
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.3.1 (2026-10-31)
|
|
4
|
+
|
|
5
|
+
- **WORKDAY with a huge holidays range** (`WORKDAY(A1,5,I1:XFD1048576)`): the days it searched were sized by the
|
|
6
|
+
range's area, so one workbook could make DuckDB fail or exhaust memory. The search now covers 2 days per holiday
|
|
7
|
+
actually in the range, never past Excel's last date.
|
|
8
|
+
|
|
9
|
+
## 0.3.0 (2026-10-31)
|
|
10
|
+
|
|
11
|
+
- **Finance:** PMT, PV, FV, NPER, NPV. Microsoft's closed forms; NPV skips text, TRUE/FALSE and empty cells in a
|
|
12
|
+
reference without spending a period on them (checked against pycel's Excel-saved npv.xlsx).
|
|
13
|
+
- **Statistics:** LARGE, SMALL, RANK(.EQ), STDEV(.S/.P/P), VAR(.S/.P/P), PERCENTILE(.INC), QUARTILE(.INC). Real Excel
|
|
14
|
+
(formulas' test.xlsx) taught two rules: k's error comes before an error in the range, and QUARTILE checks quart
|
|
15
|
+
before truncating it (QUARTILE(x, -0.1) is #NUM!).
|
|
16
|
+
- **Working days:** NETWORKDAYS and WORKDAY, with a holidays range.
|
|
17
|
+
- **Excel tables:** structured references (`Sales[Amount]`, `Sales[@Qty]`, `Sales[[#This Row],[Qty]]`, `#All`,
|
|
18
|
+
`#Data`, `#Headers`, `#Totals`, `Sales[[Rep]:[Amount]]`) are rewritten to A1 references by the reader; a
|
|
19
|
+
calculated table column compiles as a region.
|
|
20
|
+
- **LET**, nested LETs and a name bound to a range (`LET(r, A1:A9, SUM(r)/COUNT(r))`) included.
|
|
21
|
+
- **Not guessed:** edge cases of the new functions that were never checked in real Excel (zero periods, rate <= -100%,
|
|
22
|
+
payment type other than 0/1, a k that is not whole, ...) are UNRESOLVED with that reason.
|
|
23
|
+
- **Fixes found by the public corpus** (FAIL 92 -> 16, all 16 explained: 10 in LibreOffice files, 6 last-digit
|
|
24
|
+
cancellations around NPV): INDEX with a negative row or column is #VALUE!, not #REF!; SWITCH reads an empty cell as
|
|
25
|
+
0 (it matches 0, not FALSE or ""); a range where one value is expected inside an array formula is UNRESOLVED
|
|
26
|
+
instead of implicitly intersected (Excel evaluates it per element there).
|
|
27
|
+
- **Array arithmetic in aggregates**, the first slices of array evaluation: `SUM(A1:A10*B1:B10)`,
|
|
28
|
+
`SUMPRODUCT((A1:A9>5)*C1:C9)`, `MAX(IF(A1:A9="x",B1:B9))`, `SUM(IFERROR(A1:A9/B1:B9,0))`, `COUNTA(A1:A9&B1:B9)`,
|
|
29
|
+
`SUM(A1:A9^2)` and friends evaluate element by element like modern Excel - an empty element is 0, text converts
|
|
30
|
+
when it is a number and is #VALUE! otherwise, comparisons rank numbers < text < TRUE/FALSE case-insensitively,
|
|
31
|
+
concatenation writes numbers the Excel way, and the first error wins. SUM, SUMPRODUCT, MAX, MIN, AVERAGE, COUNT,
|
|
32
|
+
COUNTA and PRODUCT take arrays; IF, IFERROR and IFNA take them as their arguments. A single-cell array formula
|
|
33
|
+
(Ctrl+Shift+Enter) now compiles; one over several cells is UNRESOLVED. Plain-entered range arithmetic or IF as an
|
|
34
|
+
aggregate argument follows modern Excel (the element-wise answer), not the legacy first-row intersection - a
|
|
35
|
+
workbook an old Excel last saved can show FAILs there, with both values shown.
|
|
36
|
+
- **Approximate lookups on unsorted data** (MATCH type 1, VLOOKUP/HLOOKUP approximate, LOOKUP) over a plain numeric
|
|
37
|
+
input table: cellproof now compiles Excel's binary-search path itself - the answer is the last probe the search
|
|
38
|
+
moves right from, not the sorted bracket, and it matches Excel's own answers on files we checked (the 9.99E+307
|
|
39
|
+
last-number trick included). The SQL refuses table values that changed after translation (#STALE, UNRESOLVED)
|
|
40
|
+
instead of answering from a stale search. MATCH type -1, text, and tables with empty cells or formulas stay
|
|
41
|
+
UNRESOLVED: Excel's answer there is not derivable from the file.
|
|
42
|
+
- **Where to start:** the report groups the unresolved cells by the reason to fix first and ranks the reasons by
|
|
43
|
+
reach: a cell that reads an unresolved cell is attributed to the reason above it, so the top row of
|
|
44
|
+
"Where to start" names the fix that lets the most cells try again. report.json gains `unresolved_groups` and a
|
|
45
|
+
`blocked_by` root per unresolved cell.
|
|
46
|
+
|
|
47
|
+
## 0.2.2 (2026-10-27)
|
|
48
|
+
|
|
49
|
+
- **LOOKUP** (vector and array form). Like the other approximate lookups, UNRESOLVED on data out of order.
|
|
50
|
+
- **YEARFRAC**, all five bases, the basis written in the formula or computed. The 1,992 YEARFRAC cells of pycel's
|
|
51
|
+
test workbook all PASS; a date before 1 March 1900 (Excel's 29 February 1900) is UNRESOLVED.
|
|
52
|
+
- **Array constants** (`{0,50,100}`, `{1,"a";2,"b"}`) wherever a range is taken: `LOOKUP(x,{0,50,100},{"F","C","A"})`,
|
|
53
|
+
`MATCH(x,{...},0)`, `SUM({...})`. Used as one value (`A1*{1,2}`) they stay UNRESOLVED.
|
|
54
|
+
|
|
55
|
+
## 0.2.1 (2026-10-20)
|
|
56
|
+
|
|
57
|
+
Found by running all 85 public test workbooks of pycel, formulas and xlcalculator (`python tests/corpus.py DIR`):
|
|
58
|
+
FAIL 229 -> 10 (all 10 in files LibreOffice saved, which the report now says), no crashes.
|
|
59
|
+
|
|
60
|
+
- **Reading:** a defined name that is a formula of names (`=h+i`) no longer crashes the load; a date-formatted number
|
|
61
|
+
keeps its serial (Excel's 29 February 1900 and date-formatted negatives were lost); text escaped by the file format
|
|
62
|
+
(`_x000D_`, written for a carriage return) is decoded as Excel does.
|
|
63
|
+
- **AND/OR/XOR** skip text and empty cells in references, and typed text other than TRUE/FALSE, like Excel.
|
|
64
|
+
- **An empty or omitted result is 0:** `IF(c,,"x")`, `IFERROR(A1,"x")` with A1 empty.
|
|
65
|
+
- **EDATE/EOMONTH/MROUND/VALUE** refuse TRUE/FALSE (`#VALUE!`); `EOMONTH(0,0)` is 31.
|
|
66
|
+
- **SUMPRODUCT** of ranges of different sizes returns an error inside them before `#VALUE!`.
|
|
67
|
+
- **PROPER** accepts another cell's value (DuckDB refused the SQL) and capitalizes accented letters.
|
|
68
|
+
- **Locale-dependent text** (`"1,000"`, `"1/2/2020"`) is UNRESOLVED instead of a wrong `#VALUE!`.
|
|
69
|
+
- **Report:** warns when the file was not last saved by Excel; CHAR above 127 in a Mac-calculated file is UNRESOLVED.
|
|
70
|
+
|
|
71
|
+
From a user's practice workbook (3 PASS / 47 UNRESOLVED -> 48 PASS / 2 UNRESOLVED):
|
|
72
|
+
|
|
73
|
+
- **Implicit intersection:** a one-column or one-row range where one value is expected takes the formula's own row or
|
|
74
|
+
column (`=IF(E$3:E$41="F",B$3:B$41)`); outside it is `#VALUE!`. A range IF passes into another function is
|
|
75
|
+
UNRESOLVED (Excel gives that function the whole range).
|
|
76
|
+
- **`INDIRECT("Sales")`** of fixed text is the reference it names (dependencies included).
|
|
77
|
+
- **MODE / MODE.SNGL.**
|
|
78
|
+
- **A bare word is a name, never a column:** `=i` without a name `i` was read as column I.
|
|
79
|
+
|
|
80
|
+
## 0.2.0 (2026-10-19)
|
|
81
|
+
|
|
82
|
+
- **Renamed** from `unexcel` to `cellproof` (the old name clashed with an R package): `pip install cellproof`, command
|
|
83
|
+
`cellproof convert`, import `cellproof`, `CELLPROOF_PERF` for the benchmark, dbt project and database `cellproof`.
|
|
84
|
+
- **Lookups row-wise:** VLOOKUP, HLOOKUP, MATCH, INDEX and XLOOKUP pasted down a column compile into one statement.
|
|
85
|
+
1,000 VLOOKUPs: verify 5.7 s -> 0.1 s.
|
|
86
|
+
- **Criteria row-wise:** COUNTIFS (and SUMIF/AVERAGEIF(S) over a range holding an error) with a criterion from the row
|
|
87
|
+
no longer fall back to cell mode. 1,000 COUNTIFS: verify 29 s -> 0.1 s.
|
|
88
|
+
- **Faster compile:** a pasted-down formula is tokenized once per run. 200k-formula benchmark 31 s -> 26 s; 50k
|
|
89
|
+
VLOOKUPs 8.9 s -> 4.6 s.
|
|
90
|
+
- A lookup outside a region is about 20% slower than in 0.1.0 (one SQL form for both modes).
|
|
91
|
+
|
|
92
|
+
## 0.1.0 (2026-10-18)
|
|
93
|
+
|
|
94
|
+
First release, as `unexcel`.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: cellproof
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.1
|
|
4
4
|
Summary: Turn an Excel workbook into SQL (a dbt project on DuckDB) and prove every number matches.
|
|
5
5
|
Project-URL: Homepage, https://github.com/Nikhil414/cellproof
|
|
6
6
|
Project-URL: Issues, https://github.com/Nikhil414/cellproof/issues
|
|
@@ -83,7 +83,8 @@ The output folder holds:
|
|
|
83
83
|
|
|
84
84
|
- **`REPORT.md` / `report.json`**: every verdict, failed cells with both values, unresolved cells with the reason,
|
|
85
85
|
findings (for example a number stored as text, which Excel skips in SUM), and which blocks of rows became readable
|
|
86
|
-
table models.
|
|
86
|
+
table models. The unresolved reasons are ranked by how many cells depend on them ("Where to start"), so a long list
|
|
87
|
+
of unresolved cells says what to fix first.
|
|
87
88
|
- **A dbt project** (`dbt_project.yml`, `models/`, `seeds/input_cells.csv`) that recomputes the workbook on DuckDB.
|
|
88
89
|
It runs exactly the SQL the verifier checked.
|
|
89
90
|
|
|
@@ -110,12 +111,18 @@ reader -> regions -> dependency graph -> compiler -> verifier -> dbt emitter ->
|
|
|
110
111
|
code.
|
|
111
112
|
6. **Emit** the dbt project and the report.
|
|
112
113
|
|
|
113
|
-
|
|
114
|
-
COUNT, COUNTA, COUNTBLANK, COUNTIF(S), DATE, DATEDIF, DAY, DAYS, DAYS360, EDATE, EOMONTH, EXACT, EXP, FIND, FLOOR,
|
|
115
|
-
HLOOKUP, IF, IFERROR, IFNA, IFS, INDEX, INT, IS* (BLANK, ERR, ERROR, LOGICAL, NA, NUMBER, TEXT), LEFT, LEN,
|
|
116
|
-
LOG10, LOOKUP, LOWER, MATCH, MAX, MAXIFS, MEDIAN, MID, MIN, MINIFS, MOD, MODE, MONTH, MROUND, NA,
|
|
117
|
-
|
|
118
|
-
|
|
114
|
+
121 Excel functions are supported: ABS, AND, AVERAGE, AVERAGEIF(S), CEILING, CHAR, CHOOSE, CLEAN, CONCAT(ENATE),
|
|
115
|
+
COUNT, COUNTA, COUNTBLANK, COUNTIF(S), DATE, DATEDIF, DAY, DAYS, DAYS360, EDATE, EOMONTH, EXACT, EXP, FIND, FLOOR, FV,
|
|
116
|
+
HLOOKUP, IF, IFERROR, IFNA, IFS, INDEX, INT, IS* (BLANK, ERR, ERROR, LOGICAL, NA, NUMBER, TEXT), LARGE, LEFT, LEN, LET,
|
|
117
|
+
LN, LOG, LOG10, LOOKUP, LOWER, MATCH, MAX, MAXIFS, MEDIAN, MID, MIN, MINIFS, MOD, MODE, MONTH, MROUND, NA, NETWORKDAYS,
|
|
118
|
+
NOT, NPER, NPV, OR, PERCENTILE(.INC), PI, PMT, POWER, PRODUCT, PROPER, PV, QUARTILE(.INC), RANK(.EQ), REPLACE, REPT,
|
|
119
|
+
RIGHT, ROUND(UP/DOWN), SEARCH, SIGN, SMALL, SQRT, STDEV(.S/.P/P), SUBSTITUTE, SUBTOTAL, SUM, SUMIF(S), SUMPRODUCT,
|
|
120
|
+
SWITCH, TEXT, TEXTJOIN, TRIM, TRUE/FALSE, TRUNC, UPPER, VALUE, VAR(.S/.P/P), VLOOKUP, WEEKDAY, WORKDAY, XLOOKUP, XOR,
|
|
121
|
+
YEAR, YEARFRAC.
|
|
122
|
+
|
|
123
|
+
**Excel tables:** structured references (`Sales[Amount]`, `Sales[@Qty]`, `Sales[[#This Row],[Qty]]`, `Sales[#Totals]`,
|
|
124
|
+
`Sales[[Rep]:[Amount]]`) are rewritten to plain references when the file is read, so a calculated table column
|
|
125
|
+
compiles like any column pasted down.
|
|
119
126
|
|
|
120
127
|
**Speed** (Windows 11 laptop, measured): a 200,000-formula workbook (four formula columns over 50,000 rows, one of them
|
|
121
128
|
a running total) converts and verifies in 26 s, all PASS. 50,000 rows of VLOOKUP into a 1,000-row table: 4.6 s.
|
|
@@ -126,23 +133,38 @@ COUNTIFS/SUMIFS with a criterion from the row run at the same speed.
|
|
|
126
133
|
cellproof prefers an honest UNRESOLVED or FAIL to a guess. Known limits, each reported with a reason:
|
|
127
134
|
|
|
128
135
|
- **File formats:** `.xlsx` and `.xlsm` only (no `.xls`, `.xlsb`, `.ods`). Macros (VBA) are ignored.
|
|
129
|
-
- **Array constants** (`{0,50,100}`) work wherever a range is taken (`SUM`, `MATCH`, `LOOKUP`, `VLOOKUP`, `INDEX`...)
|
|
130
|
-
where one value is expected (`A1*{1,2}`) they need array evaluation and are UNRESOLVED.
|
|
131
|
-
- **
|
|
136
|
+
- **Array constants** (`{0,50,100}`) work wherever a range is taken (`SUM`, `MATCH`, `LOOKUP`, `VLOOKUP`, `INDEX`...)
|
|
137
|
+
and inside array arithmetic; where one value is expected (`A1*{1,2}`) they need array evaluation and are UNRESOLVED.
|
|
138
|
+
- **Array arithmetic in aggregates** (`SUM(A1:A10*B1:B10)`, `SUMPRODUCT((A1:A9>5)*C1:C9)`, `MAX(IF(A1:A9="x",B1:B9))`,
|
|
139
|
+
`SUM(IFERROR(A1:A9/B1:B9,0))`, `COUNTA(A1:A9&B1:B9)`, `SUM(A1:A9^2)`) follows modern Excel: element by element, an
|
|
140
|
+
empty element is 0, text converts when it is a number ("3" -> 3) and is #VALUE! otherwise, comparisons rank
|
|
141
|
+
numbers < text < TRUE/FALSE case-insensitively, concatenation writes numbers the Excel way, and the first error
|
|
142
|
+
wins. A single-cell array formula (Ctrl+Shift+Enter) compiles; an array formula over several cells is UNRESOLVED
|
|
143
|
+
(spilling is not read yet). A plain-entered range arithmetic or IF as an aggregate argument follows modern Excel,
|
|
144
|
+
not the legacy first-row intersection - a workbook an old Excel last saved can show FAILs there, with both values
|
|
145
|
+
shown.
|
|
146
|
+
- **Not supported:** multi-cell array formulas and dynamic arrays, volatile functions (`NOW`, `TODAY`, `RAND`, `OFFSET`, and
|
|
132
147
|
`INDIRECT` of text built while the sheet runs; `INDIRECT("Sales")` is fine), functions outside the list above,
|
|
133
|
-
external workbooks, structured
|
|
148
|
+
external workbooks, a structured reference naming several separate columns (`T[[A],[C]]`), INDEX used as a reference, the 1904 date system in
|
|
134
149
|
TEXT date formats.
|
|
135
150
|
- **Ranges where one value is expected** (`=IF(E$3:E$41="F",B$3:B$41)`) take the formula's own row or column, as
|
|
136
|
-
Excel does (implicit intersection).
|
|
137
|
-
|
|
138
|
-
- **Approximate lookups on unsorted data** (LOOKUP,
|
|
139
|
-
|
|
151
|
+
Excel does (implicit intersection). As an aggregate's argument the element-wise answer is compiled instead (see
|
|
152
|
+
array arithmetic above). IFERROR, IFS and CHOOSE over arrays are still UNRESOLVED.
|
|
153
|
+
- **Approximate lookups on unsorted data** (LOOKUP, MATCH/VLOOKUP/HLOOKUP with match type 1): compiled for plain
|
|
154
|
+
numeric tables written as inputs (up to about 1,000 values): the SQL carries Excel's binary-search path itself, and
|
|
155
|
+
refuses changed table values instead of answering from a stale search. MATCH with type -1, text tables, tables with
|
|
156
|
+
empty cells or formulas, and bigger tables stay UNRESOLVED, because Excel's answer there is not derivable from the
|
|
157
|
+
file (LibreOffice, the only open source that emulates the search, provably differs from Excel in places).
|
|
140
158
|
- **Text to number:** only plain numbers convert (`"3"`, `" -1.5e3 "`). Text Excel reads with the computer's language
|
|
141
159
|
settings (`"1,000"`, `"$5"`, `"50%"`, `"1/2/2020"`, `"2:00 PM"`, `"Jan 5"`) makes the cell UNRESOLVED, because the
|
|
142
160
|
file does not record those settings.
|
|
143
161
|
- **Who saved the file:** the report warns when it was last saved by another program (LibreOffice, a script): the
|
|
144
162
|
saved values then follow that program's rules. In a file Excel for Mac calculated, `CHAR` above 127 is UNRESOLVED
|
|
145
163
|
(the Mac character set differs).
|
|
164
|
+
- **Edge cases not checked in real Excel yet** are UNRESOLVED with that reason, never guessed: PMT/PV/FV/NPER with
|
|
165
|
+
zero periods, a rate of -100% or less or a payment type other than 0 or 1; NPV at a rate of -100%; LARGE/SMALL with
|
|
166
|
+
a k that is not whole; RANK over a range holding an error; NETWORKDAYS/WORKDAY with text or errors among the
|
|
167
|
+
holidays. NETWORKDAYS.INTL, WORKDAY.INTL, IRR, RATE and the other finance and statistics functions are not in yet.
|
|
146
168
|
- **Some function options:** SUBTOTAL 101-111 (hidden rows), DATEDIF units MD/YM/YD, WEEKDAY types 11-17, TEXT formats
|
|
147
169
|
outside the supported table, COUNT or MEDIAN of values typed into the formula, criteria taken from an empty cell.
|
|
148
170
|
- **Floating point:** a running total becomes a fast window function only when Excel's saved values prove the different
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# cellproof: progress
|
|
2
2
|
|
|
3
|
-
Last updated: 2026-10-
|
|
3
|
+
Last updated: 2026-10-31.
|
|
4
4
|
|
|
5
5
|
## State
|
|
6
6
|
|
|
@@ -18,12 +18,26 @@ Everything below is on `main`, built test-first, each piece reviewed by a fresh
|
|
|
18
18
|
| Tokenize once | a formula pasted down a column is tokenized once; the next rows' text is predicted and only re-tokenized when it differs |
|
|
19
19
|
| Implicit intersection | a one-column range where one value is expected takes the formula's row; `INDIRECT` of fixed text; MODE (found in a user's workbook) |
|
|
20
20
|
| Criteria row-wise | the *IF(S) family with a criterion from the row (`=COUNTIFS($E:$E,">"&A2,...)`) compiles into the region's statement too |
|
|
21
|
+
| Impact-ranked unresolveds | the report groups UNRESOLVED cells by the reason to fix first ("Where to start"): the compiler records which unresolved cell stopped a compile (`Unsupported.dep`), each chained cell is attributed to the first blocker its chain reaches, reasons are ranked by reach; report.json gains `unresolved_groups` and per-cell `blocked_by` |
|
|
22
|
+
| Approximate lookups unsorted | MATCH type 1 / VLOOKUP / HLOOKUP / LOOKUP over a plain numeric input table out of order compiles Excel's binary-search path (a decision tree of probes, depths and x-intervals, one aggregate in SQL; verified differentially against the bisection and against real Excel answers). A changed table is #STALE -> UNRESOLVED, never a stale answer. Type -1 and text stay UNRESOLVED (Excel's rule there is not derivable; LibreOffice differs). examples/functions.xlsx: 4 UNRESOLVED -> 2 |
|
|
23
|
+
| Arrays slices 1+2 | element-wise arrays in the aggregates: `SUM(A1:A10*B1:B10)`, `SUMPRODUCT((A1:A9>5)*C1:C9)`, `MAX(IF(A1:A9="x",B1:B9))`. An array argument is one relation with the cells table's columns (a row per element position, blanks and all), which SUM/PRODUCT/MAX/MIN/AVERAGE/COUNT/COUNTA/SUMPRODUCT read like a range; IF picks one element per position (the untaken branch's error never shows). Text converts in arithmetic ("3"->3, else #VALUE!); comparisons rank numbers < text < TRUE/FALSE case-insensitively. SUM moved from functions.py onto the aggregate machinery. A single-cell CSE formula compiles (`Cell.ref` kept from the file); multi-cell stays UNRESOLVED. Plain-entered range arithmetic/IF as an aggregate argument now follows modern Excel, not the legacy intersection - a legacy-saved workbook can FAIL there (a real user workbook's MAX(IF(...))=99 artifact surfaces as a FAIL with both values shown). Next: IFERROR/IFS/CHOOSE over arrays, & and ^ on arrays, then legacy multi-cell array formulas and dynamic arrays |
|
|
24
|
+
| 0.3.0 functions | PMT, PV, FV, NPER, NPV; LARGE, SMALL, RANK(.EQ), STDEV/VAR (S/P), PERCENTILE(.INC), QUARTILE(.INC); NETWORKDAYS, WORKDAY. Edge cases not checked in real Excel are an UNCHECKED marker (UNRESOLVED), like LOCALE |
|
|
25
|
+
| Excel tables | structured references rewritten to A1 text by the reader (`tables.py`); [#This Row] becomes a same-row reference, so a calculated column is a region |
|
|
26
|
+
| LET | names (stored `_xlpm.x`) substituted by their value's tree, shadowing respected; the graph skips them as dependencies |
|
|
21
27
|
| Open source | MIT license, README with limits, SECURITY.md, CI on Windows/macOS/Linux x Python 3.10-3.13 |
|
|
22
28
|
|
|
23
|
-
Tests:
|
|
24
|
-
purpose). Public on GitHub (one-commit history start). 0.1.0 was released as `unexcel`; 0.2.0
|
|
29
|
+
Tests: 492 (+10 skipped without dbt/Excel files), plus 3 workbooks saved by real Excel that all PASS (4 cells UNRESOLVED on
|
|
30
|
+
purpose). Public on GitHub (one-commit history start). 0.1.0 was released as `unexcel`; 0.2.0, 0.2.1, 0.2.2 and 0.3.0 (2026-10-31) are on PyPI as `cellproof` (see CHANGELOG.md).
|
|
25
31
|
A user's practice workbook: 3 PASS / 47 UNRESOLVED -> 48 PASS / 0 FAIL / 2 UNRESOLVED.
|
|
26
32
|
|
|
33
|
+
## Public test workbooks (2026-10-31)
|
|
34
|
+
|
|
35
|
+
After 0.3.0's functions, tables and LET: 7,528 PASS, 16 FAIL, 16,104 UNRESOLVED (was 7,108 / 92 / 16,448 on 0.2.2 +
|
|
36
|
+
arrays). The 16 FAIL: 10 in LibreOffice files, 6 in pycel's npv.xlsx where `=C7-A7` subtracts two numbers equal to
|
|
37
|
+
1e-13 relative (NPV's last digits differ from Excel's own arithmetic; every NPV cell itself PASSes). The 82 new FAILs
|
|
38
|
+
the arrays work exposed were INDEX with a negative index, SWITCH with an empty cell and ranges inside single-cell
|
|
39
|
+
array formulas - all fixed.
|
|
40
|
+
|
|
27
41
|
## Public test workbooks (2026-10-19)
|
|
28
42
|
|
|
29
43
|
`python tests/corpus.py DIR` runs the 85 .xlsx/.xlsm test files of pycel, formulas and xlcalculator (Excel-saved,
|
|
@@ -80,8 +94,9 @@ What Excel taught us (each has a test in `tests/test_excel_findings.py`):
|
|
|
80
94
|
|
|
81
95
|
## Next
|
|
82
96
|
|
|
83
|
-
1. Array
|
|
84
|
-
|
|
97
|
+
1. Array evaluation, next slices: IFS/CHOOSE over arrays, then legacy multi-cell array formulas and dynamic
|
|
98
|
+
arrays. (Done: element-wise arithmetic, comparisons, IF, IFERROR/IFNA, & and ^ inside the aggregates - see
|
|
99
|
+
Arrays slices 1-3 above.)
|
|
85
100
|
2. Test on more real analyst workbooks (one user workbook found 4 gaps the 85 public files did not).
|
|
86
101
|
3. Read time (openpyxl loads the workbook twice) and the per-cell dependency loop.
|
|
87
102
|
4. Plan 3: AI retry loop for failed cells (it sees formula structure only, never values).
|
|
@@ -49,7 +49,8 @@ The output folder holds:
|
|
|
49
49
|
|
|
50
50
|
- **`REPORT.md` / `report.json`**: every verdict, failed cells with both values, unresolved cells with the reason,
|
|
51
51
|
findings (for example a number stored as text, which Excel skips in SUM), and which blocks of rows became readable
|
|
52
|
-
table models.
|
|
52
|
+
table models. The unresolved reasons are ranked by how many cells depend on them ("Where to start"), so a long list
|
|
53
|
+
of unresolved cells says what to fix first.
|
|
53
54
|
- **A dbt project** (`dbt_project.yml`, `models/`, `seeds/input_cells.csv`) that recomputes the workbook on DuckDB.
|
|
54
55
|
It runs exactly the SQL the verifier checked.
|
|
55
56
|
|
|
@@ -76,12 +77,18 @@ reader -> regions -> dependency graph -> compiler -> verifier -> dbt emitter ->
|
|
|
76
77
|
code.
|
|
77
78
|
6. **Emit** the dbt project and the report.
|
|
78
79
|
|
|
79
|
-
|
|
80
|
-
COUNT, COUNTA, COUNTBLANK, COUNTIF(S), DATE, DATEDIF, DAY, DAYS, DAYS360, EDATE, EOMONTH, EXACT, EXP, FIND, FLOOR,
|
|
81
|
-
HLOOKUP, IF, IFERROR, IFNA, IFS, INDEX, INT, IS* (BLANK, ERR, ERROR, LOGICAL, NA, NUMBER, TEXT), LEFT, LEN,
|
|
82
|
-
LOG10, LOOKUP, LOWER, MATCH, MAX, MAXIFS, MEDIAN, MID, MIN, MINIFS, MOD, MODE, MONTH, MROUND, NA,
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
121 Excel functions are supported: ABS, AND, AVERAGE, AVERAGEIF(S), CEILING, CHAR, CHOOSE, CLEAN, CONCAT(ENATE),
|
|
81
|
+
COUNT, COUNTA, COUNTBLANK, COUNTIF(S), DATE, DATEDIF, DAY, DAYS, DAYS360, EDATE, EOMONTH, EXACT, EXP, FIND, FLOOR, FV,
|
|
82
|
+
HLOOKUP, IF, IFERROR, IFNA, IFS, INDEX, INT, IS* (BLANK, ERR, ERROR, LOGICAL, NA, NUMBER, TEXT), LARGE, LEFT, LEN, LET,
|
|
83
|
+
LN, LOG, LOG10, LOOKUP, LOWER, MATCH, MAX, MAXIFS, MEDIAN, MID, MIN, MINIFS, MOD, MODE, MONTH, MROUND, NA, NETWORKDAYS,
|
|
84
|
+
NOT, NPER, NPV, OR, PERCENTILE(.INC), PI, PMT, POWER, PRODUCT, PROPER, PV, QUARTILE(.INC), RANK(.EQ), REPLACE, REPT,
|
|
85
|
+
RIGHT, ROUND(UP/DOWN), SEARCH, SIGN, SMALL, SQRT, STDEV(.S/.P/P), SUBSTITUTE, SUBTOTAL, SUM, SUMIF(S), SUMPRODUCT,
|
|
86
|
+
SWITCH, TEXT, TEXTJOIN, TRIM, TRUE/FALSE, TRUNC, UPPER, VALUE, VAR(.S/.P/P), VLOOKUP, WEEKDAY, WORKDAY, XLOOKUP, XOR,
|
|
87
|
+
YEAR, YEARFRAC.
|
|
88
|
+
|
|
89
|
+
**Excel tables:** structured references (`Sales[Amount]`, `Sales[@Qty]`, `Sales[[#This Row],[Qty]]`, `Sales[#Totals]`,
|
|
90
|
+
`Sales[[Rep]:[Amount]]`) are rewritten to plain references when the file is read, so a calculated table column
|
|
91
|
+
compiles like any column pasted down.
|
|
85
92
|
|
|
86
93
|
**Speed** (Windows 11 laptop, measured): a 200,000-formula workbook (four formula columns over 50,000 rows, one of them
|
|
87
94
|
a running total) converts and verifies in 26 s, all PASS. 50,000 rows of VLOOKUP into a 1,000-row table: 4.6 s.
|
|
@@ -92,23 +99,38 @@ COUNTIFS/SUMIFS with a criterion from the row run at the same speed.
|
|
|
92
99
|
cellproof prefers an honest UNRESOLVED or FAIL to a guess. Known limits, each reported with a reason:
|
|
93
100
|
|
|
94
101
|
- **File formats:** `.xlsx` and `.xlsm` only (no `.xls`, `.xlsb`, `.ods`). Macros (VBA) are ignored.
|
|
95
|
-
- **Array constants** (`{0,50,100}`) work wherever a range is taken (`SUM`, `MATCH`, `LOOKUP`, `VLOOKUP`, `INDEX`...)
|
|
96
|
-
where one value is expected (`A1*{1,2}`) they need array evaluation and are UNRESOLVED.
|
|
97
|
-
- **
|
|
102
|
+
- **Array constants** (`{0,50,100}`) work wherever a range is taken (`SUM`, `MATCH`, `LOOKUP`, `VLOOKUP`, `INDEX`...)
|
|
103
|
+
and inside array arithmetic; where one value is expected (`A1*{1,2}`) they need array evaluation and are UNRESOLVED.
|
|
104
|
+
- **Array arithmetic in aggregates** (`SUM(A1:A10*B1:B10)`, `SUMPRODUCT((A1:A9>5)*C1:C9)`, `MAX(IF(A1:A9="x",B1:B9))`,
|
|
105
|
+
`SUM(IFERROR(A1:A9/B1:B9,0))`, `COUNTA(A1:A9&B1:B9)`, `SUM(A1:A9^2)`) follows modern Excel: element by element, an
|
|
106
|
+
empty element is 0, text converts when it is a number ("3" -> 3) and is #VALUE! otherwise, comparisons rank
|
|
107
|
+
numbers < text < TRUE/FALSE case-insensitively, concatenation writes numbers the Excel way, and the first error
|
|
108
|
+
wins. A single-cell array formula (Ctrl+Shift+Enter) compiles; an array formula over several cells is UNRESOLVED
|
|
109
|
+
(spilling is not read yet). A plain-entered range arithmetic or IF as an aggregate argument follows modern Excel,
|
|
110
|
+
not the legacy first-row intersection - a workbook an old Excel last saved can show FAILs there, with both values
|
|
111
|
+
shown.
|
|
112
|
+
- **Not supported:** multi-cell array formulas and dynamic arrays, volatile functions (`NOW`, `TODAY`, `RAND`, `OFFSET`, and
|
|
98
113
|
`INDIRECT` of text built while the sheet runs; `INDIRECT("Sales")` is fine), functions outside the list above,
|
|
99
|
-
external workbooks, structured
|
|
114
|
+
external workbooks, a structured reference naming several separate columns (`T[[A],[C]]`), INDEX used as a reference, the 1904 date system in
|
|
100
115
|
TEXT date formats.
|
|
101
116
|
- **Ranges where one value is expected** (`=IF(E$3:E$41="F",B$3:B$41)`) take the formula's own row or column, as
|
|
102
|
-
Excel does (implicit intersection).
|
|
103
|
-
|
|
104
|
-
- **Approximate lookups on unsorted data** (LOOKUP,
|
|
105
|
-
|
|
117
|
+
Excel does (implicit intersection). As an aggregate's argument the element-wise answer is compiled instead (see
|
|
118
|
+
array arithmetic above). IFERROR, IFS and CHOOSE over arrays are still UNRESOLVED.
|
|
119
|
+
- **Approximate lookups on unsorted data** (LOOKUP, MATCH/VLOOKUP/HLOOKUP with match type 1): compiled for plain
|
|
120
|
+
numeric tables written as inputs (up to about 1,000 values): the SQL carries Excel's binary-search path itself, and
|
|
121
|
+
refuses changed table values instead of answering from a stale search. MATCH with type -1, text tables, tables with
|
|
122
|
+
empty cells or formulas, and bigger tables stay UNRESOLVED, because Excel's answer there is not derivable from the
|
|
123
|
+
file (LibreOffice, the only open source that emulates the search, provably differs from Excel in places).
|
|
106
124
|
- **Text to number:** only plain numbers convert (`"3"`, `" -1.5e3 "`). Text Excel reads with the computer's language
|
|
107
125
|
settings (`"1,000"`, `"$5"`, `"50%"`, `"1/2/2020"`, `"2:00 PM"`, `"Jan 5"`) makes the cell UNRESOLVED, because the
|
|
108
126
|
file does not record those settings.
|
|
109
127
|
- **Who saved the file:** the report warns when it was last saved by another program (LibreOffice, a script): the
|
|
110
128
|
saved values then follow that program's rules. In a file Excel for Mac calculated, `CHAR` above 127 is UNRESOLVED
|
|
111
129
|
(the Mac character set differs).
|
|
130
|
+
- **Edge cases not checked in real Excel yet** are UNRESOLVED with that reason, never guessed: PMT/PV/FV/NPER with
|
|
131
|
+
zero periods, a rate of -100% or less or a payment type other than 0 or 1; NPV at a rate of -100%; LARGE/SMALL with
|
|
132
|
+
a k that is not whole; RANK over a range holding an error; NETWORKDAYS/WORKDAY with text or errors among the
|
|
133
|
+
holidays. NETWORKDAYS.INTL, WORKDAY.INTL, IRR, RATE and the other finance and statistics functions are not in yet.
|
|
112
134
|
- **Some function options:** SUBTOTAL 101-111 (hidden rows), DATEDIF units MD/YM/YD, WEEKDAY types 11-17, TEXT formats
|
|
113
135
|
outside the supported table, COUNT or MEDIAN of values typed into the formula, criteria taken from an empty cell.
|
|
114
136
|
- **Floating point:** a running total becomes a fast window function only when Excel's saved values prove the different
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.3.1"
|
|
@@ -41,7 +41,8 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
41
41
|
return 3
|
|
42
42
|
out = args.out or args.workbook.with_name(args.workbook.stem + "_dbt")
|
|
43
43
|
write_project(book, compiled, out, args.workbook.stem)
|
|
44
|
-
counts = write_report(verdicts, compiled.findings, out, args.workbook.name, computed, compiled.notes
|
|
44
|
+
counts = write_report(verdicts, compiled.findings, out, args.workbook.name, computed, compiled.notes,
|
|
45
|
+
compiled.chains)
|
|
45
46
|
if computed:
|
|
46
47
|
print(f"{len(computed)} expected values computed by the formulas library (the file had none saved)")
|
|
47
48
|
print(f"{counts['PASS']} pass, {counts['FAIL']} fail, {counts['UNRESOLVED']} unresolved -> {out / 'REPORT.md'}")
|
|
@@ -71,6 +71,7 @@ class Compiled:
|
|
|
71
71
|
unresolved: dict[Key, str]
|
|
72
72
|
findings: list[str]
|
|
73
73
|
notes: list[str] = dc_field(default_factory=list)
|
|
74
|
+
chains: dict[Key, Key] = dc_field(default_factory=dict) # cell -> the unresolved cell that stopped its compile
|
|
74
75
|
|
|
75
76
|
@property
|
|
76
77
|
def steps(self) -> list[Step]:
|
|
@@ -112,10 +113,17 @@ class Compiler:
|
|
|
112
113
|
self.rowrefs: dict[str, Expr] | None = None # same-row placeholders of a region (see regions)
|
|
113
114
|
self.at: Key | None = None # the formula cell being compiled in cell mode (implicit intersection)
|
|
114
115
|
self.ctx: list[str] = [] # what consumes the node being compiled: "op", "fn" or "pass" (PASS_THROUGH)
|
|
116
|
+
self.wid = 0 # unique aliases w1, w2... for the element sources of one array argument
|
|
117
|
+
|
|
118
|
+
def walias(self) -> str:
|
|
119
|
+
self.wid += 1
|
|
120
|
+
return f"w{self.wid}"
|
|
115
121
|
|
|
116
122
|
def compile_cell(self, cell: Cell) -> Expr:
|
|
117
|
-
if cell.
|
|
118
|
-
raise Unsupported(
|
|
123
|
+
if cell.key in self.book.unread:
|
|
124
|
+
raise Unsupported(self.book.unread[cell.key])
|
|
125
|
+
if cell.array and cell.ref and ":" in cell.ref:
|
|
126
|
+
raise Unsupported("array formula over several cells") # spilling into the neighbours is not read yet
|
|
119
127
|
self.at = cell.key
|
|
120
128
|
try:
|
|
121
129
|
return finalize(self.expr(parse(cell.formula), cell.sheet))
|
|
@@ -129,6 +137,9 @@ class Compiler:
|
|
|
129
137
|
raise Unsupported("array constant used where one value is expected (needs array evaluation) not supported yet")
|
|
130
138
|
if self.at is None or area.sheet != self.at[0] or (area.r1 != area.r2 and area.c1 != area.c2):
|
|
131
139
|
raise Unsupported(f"range {text} used as a single value")
|
|
140
|
+
if self.book.cells[self.at].array: # real Excel: {=MONTH(A1:B1)} evaluates per element, shows the first
|
|
141
|
+
raise Unsupported(f"range {text} where one value is expected in an array formula (needs array "
|
|
142
|
+
"evaluation) not supported yet")
|
|
132
143
|
# real Excel: in MAX(IF(c, A1:A9, 0)) IF hands MAX the whole range; only an operator, a function's own
|
|
133
144
|
# argument or the cell itself takes one value of it
|
|
134
145
|
for consumer in reversed(self.ctx):
|
|
@@ -238,7 +249,7 @@ class Compiler:
|
|
|
238
249
|
elif key in self.done:
|
|
239
250
|
typ, may_err = self.done[key]
|
|
240
251
|
else:
|
|
241
|
-
raise Unsupported(f"depends on unresolved cell {a1(key)}")
|
|
252
|
+
raise Unsupported(f"depends on unresolved cell {a1(key)}", key)
|
|
242
253
|
where = f"FROM {CELLS} WHERE {where_cell(key)}"
|
|
243
254
|
err = f"(SELECT CASE WHEN kind = 'e' THEN txt END {where})" if may_err else NO_ERR
|
|
244
255
|
if typ == "num":
|
|
@@ -266,7 +277,7 @@ class Compiler:
|
|
|
266
277
|
if key in self.open:
|
|
267
278
|
raise NewBatch
|
|
268
279
|
if key not in self.done:
|
|
269
|
-
raise Unsupported(f"depends on unresolved cell {a1(key)}")
|
|
280
|
+
raise Unsupported(f"depends on unresolved cell {a1(key)}", key)
|
|
270
281
|
raise AssertionError("range index is out of step with the compiler")
|
|
271
282
|
|
|
272
283
|
def kind_of(self, key: Key) -> str:
|
|
@@ -324,6 +335,7 @@ def compile_book(book: Book, regions: bool = True) -> Compiled:
|
|
|
324
335
|
scan = find_regions(book) if regions else RegionScan([], [])
|
|
325
336
|
order, unresolved, kept = order_with_regions(book, scan.regions)
|
|
326
337
|
comp = Compiler(book)
|
|
338
|
+
chains: dict[Key, Key] = {} # cell -> the unresolved cell that stopped its compile (see impact.py)
|
|
327
339
|
if book.app and not (book.app.startswith("Microsoft") and "Compatible" not in book.app): # openpyxl: "Compatible"
|
|
328
340
|
comp.findings.append(f"the file was last saved by {book.app}, not Microsoft Excel: its saved values follow that "
|
|
329
341
|
"program's rules, so a FAIL can be a difference between that program and Excel")
|
|
@@ -369,6 +381,8 @@ def compile_book(book: Book, regions: bool = True) -> Compiled:
|
|
|
369
381
|
e = comp.compile_cell(cell) # the open batch is empty now, so this can't raise NewBatch
|
|
370
382
|
except Unsupported as err:
|
|
371
383
|
unresolved[key] = str(err)
|
|
384
|
+
if err.dep is not None:
|
|
385
|
+
chains[key] = err.dep
|
|
372
386
|
return
|
|
373
387
|
except RecursionError: # Python's stack, not DuckDB's: DuckDB took 900 nesting levels in tests
|
|
374
388
|
unresolved[key] = DEEP
|
|
@@ -402,7 +416,7 @@ def compile_book(book: Book, regions: bool = True) -> Compiled:
|
|
|
402
416
|
for row in range(region.r1, region.r2 + 1):
|
|
403
417
|
add((region.sheet, row, col))
|
|
404
418
|
_close(comp, batches, current)
|
|
405
|
-
return Compiled(batches, unresolved, comp.findings, notes)
|
|
419
|
+
return Compiled(batches, unresolved, comp.findings, notes, chains)
|
|
406
420
|
|
|
407
421
|
|
|
408
422
|
def cell_row(typ: str, v: str, e: str, t: str, k: str) -> tuple[str, str, str]:
|
|
@@ -18,7 +18,15 @@ PLATFORM = "#PLATFORM" # not an Excel error either: Excel for Mac answers diffe
|
|
|
18
18
|
PLATFORM_REASON = "CHAR above 127 gives a different character in Excel for Mac, which last calculated this file"
|
|
19
19
|
EARLY1900 = "#1900" # nor this: a date before 1 March 1900, where Excel counts a 29 February that never existed
|
|
20
20
|
EARLY1900_REASON = "YEARFRAC of a date before 1 March 1900, around Excel's 29 February 1900 that never existed"
|
|
21
|
-
|
|
21
|
+
STALE = "#STALE" # nor this: a compiled binary search whose table's values changed after translation
|
|
22
|
+
STALE_REASON = ("the lookup table's values changed after the workbook was translated, so its compiled search is "
|
|
23
|
+
"out of date: re-run cellproof")
|
|
24
|
+
UNCHECKED = "#UNCHECKED" # nor this: an edge case of a function whose Excel answer was never checked in real Excel
|
|
25
|
+
UNCHECKED_REASON = ("an edge case of this function (like zero periods, a rate of -100% or less, a payment type other "
|
|
26
|
+
"than 0 or 1, a k that is not a whole number, or an error in the range) whose Excel answer has not "
|
|
27
|
+
"been checked against real Excel yet")
|
|
28
|
+
SETTINGS = {LOCALE: LOCALE_REASON, PLATFORM: PLATFORM_REASON, EARLY1900: EARLY1900_REASON,
|
|
29
|
+
STALE: STALE_REASON, UNCHECKED: UNCHECKED_REASON} # reported as UNRESOLVED
|
|
22
30
|
Type = Literal["num", "txt", "bool", "blank", "err", "any"]
|
|
23
31
|
|
|
24
32
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"""The Excel function library. Importing this package registers every function in cellproof.functions.FUNCS."""
|
|
2
|
-
from cellproof.fn import aggregate, criteria, dates, logic, lookup, maths, text # noqa: F401
|
|
2
|
+
from cellproof.fn import aggregate, criteria, dates, finance, logic, lookup, maths, stats, text # noqa: F401
|