Skip to content

HF-270: Exporter honours evaluateNullToZero for bare empty cells - #1738

Merged
marcin-kordas-hoc merged 7 commits into
developfrom
spike/hf270-null-to-zero
Nov 3, 2026
Merged

marcin-kordas-hoc merged 7 commits into
developfrom
spike/hf270-null-to-zero

Conversation

@marcin-kordas-hoc

@marcin-kordas-hoc marcin-kordas-hoc commented Aug 18, 2026 •

Copy link
Copy Markdown
Collaborator

Context

With evaluateNullToZero on, a formula that reads an empty cell returns 0, but the empty cell itself, read through the API, returned null. So getSheetValues() on [[null, '=A1']] gave [[null, 0]].

The Exporter now returns 0 for an empty cell when the option is on. getCellValue(), getSheetValues(), getAllSheetsValues(), getRangeValues() and the changes passed to the valuesUpdated event 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 with 0 up 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() returns 0 for any address outside the used area.

ISBLANK still returns TRUE for an empty cell, and getCellSerialized() still returns null.

The JSDoc of evaluateNullToZero now says that empty cells read through the API return 0.

How did you test your changes?

  • Paired branch spike/hf270-null-to-zero in hyperformula-tests (hyperformula-tests#39). The 22 tests in unit/CellValueExporter.spec.ts and unit/null-compatibility.spec.ts pass. With the Exporter.ts change reverted, 7 of them fail.
  • The values above come from a script run against this branch and against 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 0 for =Z9 and TRUE for =ISBLANK(Z9) when Z9 is 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 the valuesUpdated changes return 0 instead of null for an empty cell. The default behaviour is unchanged.

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)
  • Change to the documentation

Related issues

  1. HF-270

Checklist

🤖 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 as 0, but getCellValue(), getSheetValues(), and other value-export paths still returned null for bare empty cells. Exporter.exportValue() now maps EmptyValue to 0 when the option is enabled, so API reads and valuesUpdated payloads match formula evaluation.

evaluateNullToZero JSDoc and CHANGELOG document this behaviour. With the option off (default), nothing changes. ISBLANK still sees empty cells as blank, and getCellSerialized() still returns null.

When the option is on, sheet value exports can pad rows with 0 up to the sheet width, and getCellValue() outside the used area returns 0 instead of null.

Reviewed by Cursor Bugbot for commit 51b0079. Bugbot is set up for automated code reviews on this repo. Configure here.

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
@qunabu

qunabu commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 18, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

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

@github-actions

github-actions Bot commented Aug 18, 2026 •

Copy link
Copy Markdown

Performance comparison of head (51b0079) vs base (87e2fe0)

                                     testName |    base |   head | change
-------------------------------------------------------------------------
                                      Sheet A |  496.98 | 501.19 | +0.85%
                                      Sheet B |  162.86 |  162.5 | -0.22%
                                      Sheet T |  140.84 | 142.28 | +1.02%
                                Column ranges |  522.12 | 526.08 | +0.76%
                                Sorted lookup | 15079.3 |  15327 | +1.64%
Sheet A:  change value, add/remove row/column |   17.21 |   17.9 | +4.01%
 Sheet B: change value, add/remove row/column |  141.93 | 146.41 | +3.16%
                   Column ranges - add column |  164.28 | 164.23 | -0.03%
                Column ranges - without batch |  506.88 | 513.53 | +1.31%
                        Column ranges - batch |  128.66 | 130.67 | +1.56%

@marcin-kordas-hoc
marcin-kordas-hoc marked this pull request as ready for review August 18, 2026 05:48
@marcin-kordas-hoc

Copy link
Copy Markdown
Collaborator Author

Paired tests PR: handsontable/hyperformula-tests#39 — merge it BEFORE this one.

@marcin-kordas-hoc

Copy link
Copy Markdown
Collaborator Author

@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 Tobiadefami left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

marcin-kordas-hoc and others added 3 commits October 22, 2026 15:21
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>
@marcin-kordas-hoc

Copy link
Copy Markdown
Collaborator Author

@Tobiadefami I expanded the evaluateNullToZero JSDoc as you asked (f07c4b9, comment only) and merged develop. Your approval is on b1c3f34 from 07.09, so could you re-approve? One question before merge: with the option on, getSheetValues() now pads every row with 0 to the sheet width ([[1, null, 3], [4]] comes back as [[1, 0, 3], [4, 0, 0]]; on develop the rows stay unpadded). Is that what we want?

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread hyperformula/src/Exporter.ts Resolved
@codecov

codecov Bot commented Nov 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.29%. Comparing base (87e2fe0) to head (51b0079).

Additional details and impacted files

Impacted file tree graph

@@             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     
Files with missing lines Coverage Δ
hyperformula/src/Exporter.ts 89.33% <100.00%> (+2.66%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Tobiadefami Tobiadefami left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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().

@marcin-kordas-hoc
marcin-kordas-hoc merged commit a650605 into develop Nov 3, 2026
36 checks passed
@marcin-kordas-hoc
marcin-kordas-hoc deleted the spike/hf270-null-to-zero branch November 3, 2026 09:43
marcin-kordas-hoc added a commit that referenced this pull request Nov 4, 2026
…ide-interpreter

CHANGELOG.md: the parent's file (develop's entries for #1738, #1755, #1769
and #1816), with this branch's entry replacing the parent's HF-131 Changed
entry as before, plus this branch's Fixed entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sequba added a commit that referenced this pull request Nov 25, 2026
### 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants