Formulas is a Python library that implements an interpreter for Excel formulas, parsing and compiling Excel formula expressions. It can also compile Excel workbooks to Python code and execute them without needing a Microsoft Excel COM server. The current version is 1.3.4, released on March 11, 2026, with an active, though irregular, release cadence.
pip install formulasVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to parse and compile a basic Excel formula using the `Parser` class and how to extend the interpreter with custom Python functions. It showcases two core capabilities of the library: formula evaluation and customization.
Ensure installation with `pip install formulas[excel]` or `pip install formulas[all]` if `ExcelModel` is used.
Thoroughly test existing complex formulas after upgrading the `formulas` library to ensure consistent behavior. Refer to the project's changelog for specific parser adjustments.
Always retrieve the global functions dictionary using `formulas.get_functions()` and assign your custom function to a key (its Excel name) within that dictionary before parsing formulas that use it.
Install the library using pip: `pip install formulas`
Review the Excel file for formula validity, ensuring all cell, range, and sheet references are correct and exist. For example, if 'Sheet 1'!#REF! is the issue, verify 'Sheet 1' and the referenced cell/range within it are valid.
Ensure the Excel workbook is correctly loaded and parsed using `formulas.ExcelModel().loads(filename).finish()` before calling `calculate()`.
Review the Excel formula and the data types of its inputs. Ensure that all operands involved in arithmetic or other type-sensitive operations are of compatible types. If necessary, adjust the Excel formula or preprocess the input data to ensure type consistency.