Repository navigation
HF-270: Exporter honours evaluateNullToZero for bare empty cells - #1738
Conversation
With evaluateNullToZero: true the interpreter already coerced empty -> 0 inside formulas, but the Exporter returned null for a bare empty cell read directly - getSheetValues over [[null, '=A1']] gave [[null, 0]]. The EmptyValue branch now returns 0 when the flag is on; default behaviour is byte-identical, ISBLANK still reports true. CHANGELOG names the caveat: code using null to distinguish truly-empty under this flag needs ISBLANK. Implemented by a prep-ship lane (task HF-270), loop green after 1 iteration; verified: authored specs 22/22, eslint clean, tsc clean. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PdHPZAjciZFWqGa19Yf7it
|
Task linked: HF-270 |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
hyperformula-docs | 51b0079 | Commit Preview URL Branch Preview URL |
Oct 30 2026, 05:31 AM |
Performance comparison of head (51b0079) vs base (87e2fe0) |
|
Paired tests PR: handsontable/hyperformula-tests#39 — merge it BEFORE this one. |
# Conflicts: # CHANGELOG.md
|
@Tobiadefami — requesting your review. Write-up here: https://claude.ai/code/artifact/23606cf3-6e22-40e8-ab00-997780a674b9 (item 2) — includes the Stellar-Fusion-fork copyright note from the task description, worth reading before diving in. CI 34/34 green, 0 open threads. |
Tobiadefami
left a comment
There was a problem hiding this comment.
Looks good. Could we expand the evaluateNullToZero comment in ConfigParams.ts:120 to cover reading blank cells through the API? It currently describes only formula results.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # CHANGELOG.md
…ough the API return 0 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@Tobiadefami I expanded the |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1738 +/- ##
===========================================
+ Coverage 97.28% 97.29% +0.01%
===========================================
Files 207 207
Lines 16218 16218
Branches 3588 3589 +1
===========================================
+ Hits 15777 15779 +2
+ Misses 441 439 -2
🚀 New features to boost your workflow:
|
Tobiadefami
left a comment
There was a problem hiding this comment.
Approving at 51b0079. With the HF-270 decision to treat this as a bug fix, the breaking-change items from my last review no longer apply, and the description now lists calculateFormula().
### Context #1738 changed what the HyperFormula API returns for an empty cell when `evaluateNullToZero` is on: `0` instead of `null`. It was filed as a bug fix, under Fixed, with no migration note. But it changes what existing calls return for existing input, which `dev-docs/DEFINITION-OF-DONE.md` counts as a breaking change. Code that finds empty cells with `=== null`, or reads the rows of `getSheetValues()` by length, behaves differently after the upgrade. The maintainers decided to treat it as breaking in 4.0.0. This PR: - moves the #1738 entry from Fixed to Changed, marks it **Breaking change**, adds the row padding and the `valuesUpdated` change, and links the migration guide - adds an "Empty cells with `evaluateNullToZero`" section to `docs/guide/migration-from-3.x-to-4.0.md`, with a 3.x/4.0 table, what stays the same, and how to update code (`isCellEmpty()` instead of `=== null`) The engine is not changed. ### How did you test your changes? - Ran the same calls against `hyperformula@3.5.0` from npm and against a build of `develop`, with `evaluateNullToZero` on and off. Every 3.x and 4.0 value in the guide's table comes from those runs: `getCellValue()` (an empty cell and an address outside the used area), `getSheetValues()`, `getAllSheetsValues()`, `getRangeValues()`, `calculateFormula('=A1:C1', 0)`, and the `newValue` of a cleared cell in both the returned changes and `valuesUpdated`. Also checked what stays the same: `getCellSerialized()`, `isCellEmpty()`, `getCellType()`, `ISBLANK()`, and a formula reading the empty cell. With the option off, both versions return the same values. - `npm run docs:lint` passes, and `npm run docs:build` completes with 229 pages. - Checked that the API anchors the section links to (`#iscellempty`, `#getcellserialized`, `#evaluatenulltozero`) exist in the generated API reference. ### AI assistance Claude Code made the changes, ran the checks and wrote this description. ### Compatibility with Excel and Google Sheets Not applicable. Formula results do not change. | Formula | Excel | Google Sheets | HyperFormula | |---|---|---|---| | | | | | ### Public API changes None in this PR. It documents the change #1738 already made: with `evaluateNullToZero: true`, the methods that export cell values return `0` instead of `null` for an empty cell. ### Out of scope and follow-ups None. ### Types of changes - [ ] Breaking change (existing functionality no longer works as before) – agreed with the maintainers - [ ] New feature or improvement (a non-breaking change that adds functionality) - [ ] Bug fix (a non-breaking change that fixes an issue) - [ ] Additional language file, or a change to an existing language file (translations) - [x] Change to the documentation ### Related issues 1. HF-270 ### Checklist - [x] My pull request meets the [Definition of Done](https://github.com/handsontable/hyperformula/blob/develop/dev-docs/DEFINITION-OF-DONE.md). External contributors: see also [Contributing to HyperFormula](https://handsontable.com/docs/hyperformula/guide/contributing.html). - [x] I have signed the [Contributor License Agreement](https://goo.gl/forms/yuutGuN0RjsikVpM2). - [x] I read my own diff end to end before requesting a review. - [x] I added a [CHANGELOG.md](https://github.com/handsontable/hyperformula/blob/develop/CHANGELOG.md) entry, written by [the changelog rules](https://github.com/handsontable/hyperformula/blob/develop/dev-docs/DOC-STANDARDS.md#the-changelog) – or none is needed (docs, tests or tooling only). - [x] I updated the documentation and JSDoc to match the change. - [x] Breaking change only: I added a section to the migration guide. - [x] I updated the `dev-docs/` pages this change affects – or none needed it. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Context
With
evaluateNullToZeroon, a formula that reads an empty cell returns0, but the empty cell itself, read through the API, returnednull. SogetSheetValues()on[[null, '=A1']]gave[[null, 0]].The Exporter now returns
0for an empty cell when the option is on.getCellValue(),getSheetValues(),getAllSheetsValues(),getRangeValues()and the changes passed to thevaluesUpdatedevent now agree with what formulas see. With the option off, which is the default, nothing changes.Two consequences with the option on:
getSheetValues()fills each row with0up to the sheet's width, instead of ending the row at its last non-empty cell.buildFromArray([[1], [1, 2, 3]])reads back as[[1, 0, 0], [1, 2, 3]].getCellValue()returns0for any address outside the used area.ISBLANKstill returnsTRUEfor an empty cell, andgetCellSerialized()still returnsnull.The JSDoc of
evaluateNullToZeronow says that empty cells read through the API return0.How did you test your changes?
spike/hf270-null-to-zeroinhyperformula-tests(hyperformula-tests#39). The 22 tests inunit/CellValueExporter.spec.tsandunit/null-compatibility.spec.tspass. With theExporter.tschange reverted, 7 of them fail.develop.Compatibility with Excel and Google Sheets
Not applicable. Formula results do not change; only values read through the API do. For reference, Excel Online gives
0for=Z9andTRUEfor=ISBLANK(Z9)whenZ9is empty. With the option on, HyperFormula now gives the same values for those formulas and for the empty cell read through the API.Public API changes
With
evaluateNullToZero: true,getCellValue(),getSheetValues(),getAllSheetsValues(),getRangeValues(),calculateFormula()and thevaluesUpdatedchanges return0instead ofnullfor an empty cell. The default behaviour is unchanged.Out of scope and follow-ups
None.
Types of changes
Related issues
Checklist
dev-docs/pages this change affects – or none needed it.🤖 Generated with Claude Code
Note
Low Risk
Behaviour change only when evaluateNullToZero is enabled; default config is unchanged and formula results are unaffected.
Overview
With
evaluateNullToZero: true, formulas already treated empty references as0, butgetCellValue(),getSheetValues(), and other value-export paths still returnednullfor bare empty cells.Exporter.exportValue()now mapsEmptyValueto0when the option is enabled, so API reads andvaluesUpdatedpayloads match formula evaluation.evaluateNullToZeroJSDoc and CHANGELOG document this behaviour. With the option off (default), nothing changes.ISBLANKstill sees empty cells as blank, andgetCellSerialized()still returnsnull.When the option is on, sheet value exports can pad rows with
0up to the sheet width, andgetCellValue()outside the used area returns0instead ofnull.Reviewed by Cursor Bugbot for commit 51b0079. Bugbot is set up for automated code reviews on this repo. Configure here.