Repository navigation
Fix string counting and truncation for cell length limitation #2205 - #2206
Merged
Merged
Conversation
Signed-off-by: Hiroshi Ohtake (torotake) <torotake@gmail.com>
xuri
requested changes
Sep 1, 2025
xuri
left a comment
Member
There was a problem hiding this comment.
Thanks for your PR. I've left some comments.
2 tasks done
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2206 +/- ##
=======================================
Coverage 99.24% 99.24%
=======================================
Files 32 32
Lines 30574 30581 +7
=======================================
+ Hits 30343 30350 +7
Misses 153 153
Partials 78 78
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
xuri
approved these changes
Sep 1, 2025
xuri
left a comment
Member
There was a problem hiding this comment.
I've made some changes based on your branch, the code review issues have been fixed.
ijustyce
pushed a commit
to ijustyce/excelize
that referenced
this pull request
Jun 15, 2026
…length limitation (qax-os#2206)
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.
PR Details
Add UTF-16 code unit aware helpers (utf16UnitCountInString, truncateUTF16Units) and update sheet name validation to use code unit length.
Description
This change introduces two new internal helpers:
Sheet name validation (checkSheetName) now enforces the 31 unit limit using UTF-16 code units instead of plain rune count, aligning behavior with Excel’s internal UTF-16 length semantics (emoji / supplementary characters consume two units). This prevents accepting names that Excel would later reject or truncating inside a surrogate pair in downstream consumers.
Related Issue
#2205
Motivation and Context
The Excel limit is effectively a UTF-16 unit, not a Unicode scalar number.
The previous length check did not properly handle strings containing surrogate pairs, resulting in problematic Excel files.
This will be fixed so that correct Excel files are output.
How Has This Been Tested
Testing Environment:
Go version: go version go1.24.2 darwin/arm64
OS: macOS 15.5
Types of changes
Stricter rejection of sheet names that previously slipped through when they exceeded the true UTF-16 unit limit via supplementary characters. This aligns behavior with Excel and is considered a correctness fix.
Checklist