Changing cell number format to 'text' doesn't work for .xls #987
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#987
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?
Here's a fiddle:
https://jsfiddle.net/jq0cr4gu/
All the cells should be formatted as 'Text' however opening the file in Excel they're formatted as 'General'.
If I instead change the above code to write the file as .xlsx I get the correct cell formatting. End goal here is to preserve leading zeros in numeric fields, but we need the compatibility of .xls.
Is this an expected limitation?
The BIFF2/5/8 XLS formats are not currently persisting the number formats. You can still pass numbers as text and the values will be stored as text.
Note: Passing
@
as the format won't preserve the leading zeroes. If you are passing a raw number, you actually need a format that mandates leading zeroes like0000000000
. The reason it "seems to work" for both XLS and XLSX is that you were actually passing a text string. Here's a fiddle showing the difference between passing text and numeric values: https://jsfiddle.net/oq7Lo3m0/I see that the leading zeros are preserved initially, but as soon as you edit the number the leading zeros are stripped.
So do I understand correctly that unless we want to bump up to a more modern workbook type we're out of luck?
Wow, appreciate the quick turnaround. We grabbed the latest version and it's working great. Thank you 👍