gridcraft/docs/decisions.md

1.7 KiB

Engineering decisions

Preserve array evaluation when exporting formulas (#64)

GridCraft evaluates ordinary formulas with array semantics even when the final result occupies one cell. XLSX export marks actual spills and formulas whose results may differ under legacy implicit intersection as dynamic, using the spill range or a single-cell array reference. Legacy CSE array ranges keep their existing representation.

The exporter inspects the parsed formula without evaluating it. It distinguishes range-taking functions such as SUM from scalar arguments and operators: SUM(A1:A3) and A1*2 stay ordinary, while SUM(A1:A3*B1:B3) and SQRT(A1:A3) retain array evaluation. Legacy array-aware contexts such as SUMPRODUCT do not need an extra marker. Explicit @ scalarizes its result without hiding array-sensitive operations inside it.

Names are resolved using workbook/sheet scope, and structured references distinguish one table-row cell from a column. Literal INDIRECT and INDEX arguments permit tighter classification; unresolved reference dimensions are conservatively treated as potentially multiple cells. Name/AST traversal is bounded, with array preservation as the fallback. This is an export classifier, not a claim of exact Excel metadata parity for every function or user-defined function. It stays within the format crate's existing dependencies and does not change calculation or import behavior.

This is a writer policy; interpreting implicit intersection in imported legacy formulas remains separate work. See Microsoft's Formula vs. Formula2 documentation.