Possible to add a worksheet with a name Excel doesn't like #376
Labels
No Label
DBF
Dates
Defined Names
Features
Formula
HTML
Images
Infrastructure
Integration
International
ODS
Operations
Performance
PivotTables
Pro
Protection
Read Bug
SSF
SYLK
Style
Write Bug
good first issue
No Milestone
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sheetjs/sheetjs#376
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This isn't a bug, more of a safety guard that's absent and thus a caution for API users. It is possible to create a workbook with a seemingly-valid sheet name that Excel cannot open.
According to this source there are seven characters not allowable as tab names:
\ / * [ ] : ?
whereas ampersands&
should be allowable.However, if a sheet name contains an ampersand, the workbook generates an error on opening.
Excel could not open wb.xlsx because some content is unreadable. Do you want to open and repair this workbook?
Internally, Excel expects the character
&
to be escaped as&.
So right now it's up to the API user to escape special characters in worksheet names.I ran into this in production yesterday, so this isn't an unusual edge case.
It looks like a bug to me, the library should properly escape the worksheet names before writing them to workbook.xml (ampersand and other characters that require escaping in xml).
Excel has a whole host of issues with sheet names. It cannot handle & : [ ] \ / ? and has a maximum length of 31 characters.
Here are the "rules":
: \ / ? * [ ]
0 < length < 32
_xHHHH_
form, so it's possible to make a sheet with a newline character! However, the length only applies to the decoded characters, so a name likecan be encoded as
1234567890_x000d_1234567890_x000d_123456789
So definitely js-xlsx should do something. It's unclear to me how far it should go.
js-xlsx definitely should encode/decode the tab names, so the JS interface works with JS strings and the XLSX writer/reader interface with the encoded values.
I am not sure how js-xlsx should handle invalid names. Should it
A) throw an error (something about an invalid sheet name)
B) try to "fix" the name by replacing bad characters
Related to this is duplicated SheetNames entries. If a name shows up twice in the
SheetNames
array (like["Sheet1", "Sheet2", "Sheet2"]
) how should it be handled?We started the process by adding a function
check_wb
that is called at the start of thewrite
function. We will slowly add the recommendations here. Currently it throws an error, but that can change if you think we should pass errors in a different way