$ show vinci1it2000/formulas
This repository is a Python library and CLI application for parsing, compiling, and calculating Excel formulas and workbooks entirely outside Microsoft Excel. It loads .xlsx, .ods, and JSON model files, builds a directed acyclic computation graph with the schedula library, and evaluates formulas cell-by-cell with support for array formulas, circular references, custom functions, LAMBDA/LET, unit conversions, and sub-model extraction. Primary APIs include ExcelModel, Parser, Ranges, and get_functions(), with additional entry points through a Click CLI (calc, build, test, serve) and a Flask-based web application. Architecturally, the project is a library with CLI and web wrappers. Formula text is tokenized and parsed into an AST, then compiled by AstBuilder into a schedula dispatch pipeline. Workbook loading, reference resolution, and cyclic reference handling are coordinated in the excel package, while hundreds of Excel function implementations are organized in categories such as math, statistics, financial, text, lookup, engineering, and date/time. The function layer relies heavily on numpy, scipy, pandas, statsmodels, and numpy-financial, and uses standardized wrappers to convert Python functions into Excel-compatible array functions with proper error propagation. Strengths include a broad data-driven test suite, an elegant range algebra class, Tarjan-based cycle detection, and a mature parser design. Weaknesses include very large function modules that mix many edge cases, incomplete Excel function categories (Automation, Cube, Database, Web), legacy Python-version conditionals, and heavy external dependencies that may lag behind current Excel behavior. Although the repo contains curated data files and spreadsheet fixtures, its dominant character is a software application rather than a data pipeline or research repository.
The LLM identified 4 files worth highlighting for reuse:
Implements Tarjan's algorithm for enumerating simple cycles in the workbook dependency graph, enabling detection and handling of circular references. This is a self-contained, non-trivial graph algorithm that can be extracted and reused in any project needing cycle detection over directed graphs.
Provides a Ranges class supporting set-like operations such as union, intersection, subtraction, and simplification on cell ranges, plus assembly of range values. The implementation is isolated around grid coordinates and can be lifted into other spreadsheet, grid, or tabular tools with minimal modification.
Defines wrap_ufunc and wrap_func decorators that standardize how Python/numpy functions expose Excel semantics: input coercion, array shape normalization, error propagation, and scalar/array results. This is a reusable pattern for building extensible formula engines or adapting scientific functions to spreadsheet-style APIs.
A tokenizer and parser that converts Excel formula strings into a typed AST, handling operator precedence, function arguments, references, and array constants. The design is well-structured and tested, and the parsing strategy can be adapted for other formula languages or configuration expression languages.