r/Python • u/Manfr3dMacx • Mar 03 '26
Showcase formualizer: an Arrow-backed spreadsheet engine - 320+ functions, incremental recalc, PyO3 + Rust
pip install formualizer
import formualizer as fz
# Recalculate every formula in an xlsx and write it back - one call
fz.recalculate_file("model.xlsx", output="recalculated.xlsx")
# Or drive it programmatically
wb = fz.load_workbook("model.xlsx")
wb.set_value("Assumptions", 3, 2, 0.08) # swap in a new interest rate
wb.evaluate_all()
print(wb.evaluate_cell("Summary", 5, 3)) # =IRR(...)
print(wb.evaluate_cell("Summary", 6, 3)) # =NPV(...)
print(wb.evaluate_cell("Summary", 7, 3)) # =PMT(...)GitHub: https://github.com/psu3d0/formualizer Docs: https://www.formualizer.dev
Why this exists
Python's Excel formula situation sucks:
openpyxl reads and writes
.xlsxperfectly, evaluates zero formulas. Cells with=SUM(A1:A10)returnNoneunless Excel already cached the values when someone last saved the file.xlcalc actually evaluates, but covers around 50 functions.
XLOOKUP,SUMIFSwith multiple criteria,IRR,XIRR, dynamic arrays (FILTER,UNIQUE,SORT), etc don't exist.xlwings works if Excel is installed on the machine. Useless in Docker or on Linux.
The standard workaround - pre-calculate in Excel, save cached values, read with openpyxl - falls apart when someone changes the model, or you need to evaluate the same workbook across thousands of different inputs. Or even just need to evaluate real workbooks of non-trivial size.
formualizer is a Rust formula engine with PyO3 bindings. No Excel. No COM. Runs anywhere Python runs.
Bonus: register Python functions as Excel formulas
def risk_score(grid):
flat = [v for row in grid for v in row]
return sum(v ** 2 for v in flat) / len(flat)
wb.register_function("RISK_SCORE", risk_score, min_args=1, max_args=1)
wb.set_formula("Sheet1", 5, 1, "=RISK_SCORE(A1:D100)")
result = wb.evaluate_cell("Sheet1", 5, 1)Your callback participates in the dependency graph like any built-in - change a cell in A1:D100 and it recalculates on the next evaluate_all().
Comparison
| Library | Evaluates | Functions | Dep. graph | Write xlsx | No Excel | License |
|---|---|---|---|---|---|---|
| formualizer | ✅ | 320+ | ✅ incremental | ✅ | ✅ | MIT / Apache-2.0 |
| xlcalc | ✅ | ~50 | partial | ❌ | ✅ | MIT |
| openpyxl | ❌ | — | ❌ | ✅ | ✅ | MIT |
| xlwings | ✅ | ~400* | ❌ | ✅ | ❌ | BSD |
Formal benchmarks are in progress. Rust core, incremental dependency graph (only affected cells recalculate on edits), MIT/Apache-2.0.
This library is fast.
What My Project Does
Python library for evaluating Excel formulas without Excel installed. Rust core via PyO3. 320+ Excel-compatible functions, .xlsx read/write, incremental dependency graph, custom Python formula callbacks, deterministic mode for reproducible evaluation. MIT/Apache-2.0.
Target Audience
Data engineers pulling business logic out of Excel workbooks, fintech/insurance teams running server-side formula evaluation (pricing, amortization, risk), SaaS builders who need spreadsheet logic without a server-side Excel dependency.
4
u/Danisaski Mar 04 '26
As someone that uses Excel and Python daily, and is refactoring some tools to Rust, just take my upvote, please.