Add (*File).Recalc to evaluate formulas and persist cached values
Author: krystophnyCreated Apr 20, 2026Updated May 25, 2026
Labelsenhancement
Problem
excelize has no "open → recalc → save" workflow. A consumer that wants it hits three walls:
- No cached-value writer.
SetCellFloat/SetCellStr/ etc. callremoveFormula, which deletes<f>and wipes shared-formula children. - Round-tripping.
CalcCellValuereturns astring; writing it back viaSetCellValuerecordst="s". Aggregates over that shared-string blob return 0. - 3D references:
SUM(Sheet1:Sheet3!A1)unquoted →#NAME? invalid reference.SUM('Sheet1':'Sheet3'!A1)quoted → parses, butrangeResolveroverwritessheetper iteration and evaluates only the last sheet.
Proposal
Add two exported methods:
func (f *File) RecalcCell(sheet, cell string) error
func (f *File) Recalc(opts ...RecalcOptions) errorRecalcCell evaluates one formula cell and writes the typed result into <v>/<t>, preserving <f> and shared-formula grouping. Recalc walks formula cells and calls RecalcCell on each. Dependency resolution reuses the existing recursive calcCellValue evaluator; circular references are bounded by MaxCalcIterations.
Scope
Four narrow PRs split under this umbrella, each with its own tracking issue where appropriate:
- 3D references, unquoted form.
parseReferencerecognises<sheetA>:<sheetB>!<ref>and expands in workbook order; aggregates consume the expanded matrix. CoversSUM(Jänner:Dezember!M40)etc. Closes this issue (partial). RecalcCell+ privatesetCellCachedValuehelper +ErrCellNoFormulasentinel. Tracked in #2307.File.Recalcwhole-workbook sweep built onRecalcCell, aggregating failures viaerrors.Join. Closes this issue.RecalcOptions{Sheet, Ref}scoping forFile.Recalc. Tracked in #2308.
Out of scope (tracked elsewhere)
- Quoted 3D references (
SUM('A':'B'!ref)) — mis-tokenised bygithub.com/xuri/efpupstream ofparseReference. Tracked in #2309.
Not needed (verified)
_xlfn.prefix stripping already works (calc.go:210).ISOWEEKNUMandSHEETare registered and correct.
Source: qax-os/excelize