Cherry-pick #50 + add regression tests for richText shared-string dedup#66
Merged
Merged
Conversation
Covers the bug fixed in the cherry-picked commit: richText objects previously collapsed to hash key '[object Object]', deduping every richText cell into a single shared-string entry. Tests verify both correct deduplication and distinction by formatting.
protobi-pieter
added a commit
that referenced
this pull request
May 7, 2026
Fixes critical bug in WorkbookWriter streaming with useSharedStrings: every richText cell collapsed into a single shared-string entry (richText objects coerced to '[object Object]' as hash key, deduping all of them). Cherry-picked from #50 by @gwkline; adds regression tests covering richText deduplication and formatting-aware distinction. Addresses upstream exceljs#2267. Also pins uuid to ^9.0.1 to keep browserify build working (uuid@14 dropped the main field; uuid@11 ships ES2021 syntax that browserify@16 cannot parse). Adds AGENTS.md with hard rules for AI-generated PRs. Files changed: - lib/utils/shared-strings.js: hash richText by rendered XML - spec/unit/utils/shared-strings.spec.js: 2 new regression tests - AGENTS.md: new (hard rules for AI agents) - README.md, CONTRIBUTING.md: pointers to AGENTS.md, release notes - .github/PULL_REQUEST_TEMPLATE.md: per-PR checklist - FORK.md: release notes - package.json, package-lock.json: version bump, uuid 8 -> 9 Tests: 886 unit tests passing (4 in SharedStrings, up from 2). PRs: #64 (uuid), #65 (AGENTS.md), #66 (richText fix)
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.
Summary
Cherry-picks protobi/exceljs#50 by @gwkline and adds the regression tests it was missing.
The bug:
SharedStrings.add()usedvaluedirectly as a hash key. For richText values (objects with arichTextarray), JavaScript coerces the object to the string"[object Object]", so every richText cell deduped into a single shared-string entry — corrupting the workbook's strings table.The fix (cherry-picked): When the value is a richText object, hash by its rendered XML representation instead. Plain strings are unchanged.
This PR also adds unit tests covering:
Without these tests, the bug could silently regress.
Upstream context
This bug was first reported as exceljs/exceljs#2267 (May 2023, @techiesalman). An alternative fix was opened upstream as exceljs/exceljs#2588 (Nov 2023, @PetrChalov) but has been stale since Feb 2024. @gwkline rediscovered the bug independently and submitted a different fix to the protobi fork. The regression tests added in this PR cover both fix approaches.
Files changed
lib/utils/shared-strings.js— cherry-picked from fix: use XML hash for streaming shared strings #50 (commit5f89673): importSharedStringXformlazily, hash richText by rendered XMLspec/unit/utils/shared-strings.spec.js— two new test casesTest plan
npm run test:unit # 4 passing in SharedStrings (was 2 before this PR)Confirmed the new tests fail without the cherry-picked fix:
These failures are exactly the regression: every richText collapses to index 0.
Related to source code