fix(sheet): strip a leading = from formulas - #4
Merged
Merged
Conversation
OOXML stores formulas without the = that users type in Excel, but
setCell({ formula: '=SUM(A1)' }) wrote <f>=SUM(A1)</f> verbatim and
Excel asked to repair the file. It is the most common usage mistake.
normalizeFormula() now removes exactly one leading =, so '=SUM(A1)' and
'SUM(A1)' are equivalent and formula() always returns the stored form.
A formula that is only '=' throws a TypeError instead of silently
producing an empty <f>; empty, null and undefined still mean no formula.
Document the behaviour in the README and mark the item done in docs/.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
4a4c53
force-pushed
the
claude/fix-formula-leading-equals
branch
from
September 6, 2026 15:46
6494528 to
d8e72ca
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resumen
OOXML almacena las fórmulas sin el
=que el usuario teclea en Excel, perosetCell({ formula: '=SUM(A1)' })escribía<f>=SUM(A1)</f>tal cual y Excel pedía reparar el archivo. Es el error de uso más habitual de la librería.Cambios
normalizeFormula()ensrc/sheet.tselimina exactamente un=inicial, así que'=SUM(A1)'y'SUM(A1)'son equivalentes yformula()devuelve siempre la forma almacenada. Solo se quita uno:'=A1=B1'queda comoA1=B1.=lanzaTypeErroren lugar de producir un<f>vacío en silencio. Una fórmula que no sea cadena también se rechaza.'',nullyundefinedsiguen significando "sin fórmula" (sin cambios de compatibilidad).docs/bugs.mdydocs/roadmap.md: punto marcado como hecho.Verificación
pnpm testsheet.test.tsyroundtrip.test.ts)pnpm test:coveragepnpm lint,pnpm typecheck,pnpm build{ formula: '=SUM(A1:B1)' }<f>SUM(A1:B1)</f>