Repository navigation
JSE-F5: sheet names count code points, as Excel does - #122
Merged
Merged
Conversation
Excel for Mac accepts a sheet name of 30 x's and an emoji: 31 code points, 32 UTF-16 units (conformance check, 2026-11-17). The validator counted UTF-16 units (name.length > 31), so the writer rejected names Excel accepts. - validateSheetName (and so the writer) counts code points. - sanitizeSheetName cuts to 31 code points, never splitting a surrogate pair, and still drops an apostrophe the cut leaves at the end. - History stays reserved in any case; sanitize turns it into "Sheet", which react-data-export's legacy components rely on. - Tests: 30 x + emoji accepted, 31 x + emoji rejected, 31 and 32 emoji, truncation, the writer end to end.
4 tasks
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.
Stacked on #121 (the
Historyconfirmation). This branch contains #121's commit, so merge #121 first; this diff then shrinks to the JSE-F5 commit alone.Excel for Mac accepts a sheet name of 30 ×
x+ 😀, which is 31 code points and 32 UTF-16 units (conformance check, 2026-11-17).validateSheetNamecounted UTF-16 units (name.length > 31), so the writer threwINVALID_SHEET_NAMEfor names Excel accepts.Changes (
src/sheet-names.ts)validateSheetName, and therefore the writer, limit a name to 31 code points.sanitizeSheetNamecuts long names to 31 code points and never splits a surrogate pair. It still removes an apostrophe the cut leaves at the end.Historyis unchanged: reserved in any case (Excel refuses it with "History is a reserve word"), andsanitizeSheetNameturns it intoSheet. react-data-export's legacy components rely on that: they sanitize, warn, then add(2)suffixes for duplicates.x+ 😀 (31 cp, 32 units)xx+ 😀 (32 cp)xHistory,history,HISTORYSheetTests
test/write/writer-features.test.ts: the cases above, truncation, the trailing apostrophe after a cut, and the writer end to end (it accepts 30 x + 😀 and rejects one more). The existing sanitize test's expectation for 30 x + 😀 changes fromxxx…xto the name kept as is. Full suite: 949 pass.docs/api.md§3.3 and thesanitizeSheetNamesignature comment are updated. Patch changeset.