Documentation
Install
# Python 3.9+ (Linux, macOS, Windows) pip install calcwright --find-links https://github.com/Huckcity/calcwright/releases/expanded_assets/v0.1.0 # Node 18+ (WebAssembly) npm install https://github.com/Huckcity/calcwright/releases/download/v0.1.0/calcwright-0.1.0.tgz # CLI: download a binary for your platform https://github.com/Huckcity/calcwright/releases/latest
PyPI and npm listings are on the way; until then these commands install the same builds from the GitHub release.
Python
import calcwright wb = calcwright.load("model.xlsx") wb["Inputs!B2"] = 42 # numbers, text, bools, dates, None wb["Inputs!B9"] = "=B2*2" # strings starting with = are formulas wb["Out!C10"] # value (recalculates if inputs changed) wb["Out!A1:D20"] # list of rows wb.evaluate("=SUMIFS(C:C,A:A,\"EU\")", at="Out!A1") wb.verify() # compare with the values Excel saved wb.save("out.xlsx"); wb.to_bytes()
Error values come back as calcwright.ExcelError("#N/A") objects rather than exceptions, so a model with an error in one cell still returns everything else. Blank cells are None.
Command line
calcwright run model.xlsx Inputs!B2=42 Inputs!B3="EU" --get Out!C10 --json calcwright recalc model.xlsx -o model-calculated.xlsx # fill in values (e.g. after openpyxl) calcwright verify *.xlsx # does each book calculate the same? calcwright eval model.xlsx Out!A1 "=XLOOKUP(5,A:A,B:B)" calcwright functions
Node
import { Workbook, installLicence } from "calcwright"; const wb = Workbook.fromBytes(fs.readFileSync("model.xlsx")); wb.set("Inputs!B2", 42); wb.get("Out!C10"); // errors are {error:"#N/A"} fs.writeFileSync("out.xlsx", wb.toBytes());
Licences
Without a key, Calcwright calculates workbooks of up to 2,000 formula cells. Install a key with calcwright licence install <key> (stored in ~/.config/calcwright/licence.key), set CALCWRIGHT_LICENSE, or call calcwright.install_licence() / installLicence(). Keys are checked offline against a public key compiled into the library; nothing phones home. A key covers every build released during its 12 months of updates, for good.
What's supported
473 functions, array formulas (CSE) and dynamic arrays with spill references, LET and LAMBDA with MAP, REDUCE, SCAN, BYROW, BYCOL and MAKEARRAY, structured table references, defined names (sheet and workbook scope), 3D references, external-workbook references read from the cached link values, what-if data tables, iterative calculation, 1900 and 1904 date systems, and Excel's text collation, number formats (TEXT) and near-zero rounding.
Not supported
VBA macros and add-in (XLL) functions, refreshing external data connections, GETPIVOTDATA, locale-specific number formats from non-English Excel installations, and legacy binary .xls files (save them as .xlsx).