SSF - format not supported #2695

Open
opened 2022-05-25 14:35:44 +00:00 by alonkh2 · 4 comments
alonkh2 commented 2022-05-25 14:35:44 +00:00 (Migrated from github.com)

I have been using SSF in my project, and have run into this problem - when the format is "#,0" it seems to throw an error. That is a valid excel format.

image

Error: unsupported format |#,0|
Component: write_num_flt
Stack: at write_num_flt (ssf.js:498)
at write_num (ssf.js:616)
at eval_fmt (ssf.js:824)
at format (ssf.js:940)

I have been using SSF in my project, and have run into this problem - when the format is "#,0" it seems to throw an error. That is a valid excel format. ![image](https://user-images.githubusercontent.com/67429638/170287801-2dfaafa1-f94a-4e0a-b426-7393cd60d962.png) Error: unsupported format |#,0| Component: write_num_flt Stack: at write_num_flt (ssf.js:498) at write_num (ssf.js:616) at eval_fmt (ssf.js:824) at format (ssf.js:940)
SheetJSDev commented 2022-05-25 15:11:22 +00:00 (Migrated from github.com)

Excel appears to be auto-correcting #,0 to #,##0. You can create a new file with

var wb = XLSX.utils.book_new();
var ws = XLSX.utils.aoa_to_sheet([[12345.6789]]);
ws["A1"].z = "#,0";
XLSX.utils.book_append_sheet(wb, ws, "Sheet1");
XLSX.writeFile(wb, "issue2695.xlsx");

(https://jsfiddle.net/c91Lotas/ live example) Excel 2019 en-US appears to treat it as number with thousands separator and zero decimal places

Excel appears to be auto-correcting `#,0` to `#,##0`. You can create a new file with ```js var wb = XLSX.utils.book_new(); var ws = XLSX.utils.aoa_to_sheet([[12345.6789]]); ws["A1"].z = "#,0"; XLSX.utils.book_append_sheet(wb, ws, "Sheet1"); XLSX.writeFile(wb, "issue2695.xlsx"); ``` (https://jsfiddle.net/c91Lotas/ live example) Excel 2019 en-US appears to treat it as number with thousands separator and zero decimal places
alonkh2 commented 2022-05-26 09:04:33 +00:00 (Migrated from github.com)

I can see that, but is the library going to support that?

I can see that, but is the library going to support that?
SheetJSDev commented 2022-05-27 04:11:01 +00:00 (Migrated from github.com)

It's an interesting question. The current approach is to stick the autocorrected formats in the main file processing library, but it probably should be added to the library.

It's an interesting question. The current approach is to stick the autocorrected formats in the main file processing library, but it probably should be added to the library.
alonkh2 commented 2022-06-12 07:56:17 +00:00 (Migrated from github.com)

could you refer me to the code relating to this?

could you refer me to the code relating to this?
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sheetjs/sheetjs#2695
No description provided.