Number format with condition that matches negative numbers gives incorrect output #2586

Open
opened 2020-09-30 22:56:01 +00:00 by snoopyjc · 1 comment
snoopyjc commented 2020-09-30 22:56:01 +00:00 (Migrated from github.com)

Format with a condition and including a - sign loses the extra - sign:

console.log(SSF.format('[<=9999999]###\\-####;\\(###\\)\\ ###\\-####', -12.3))
-12.3

Excel gives --12.3 (one from the \- and one from the negative number).

Possibly related, this one is wrong too:

console.log(SSF.format('[=0]?;#,##0.00', -12.3))
12.3

(loses the - sign)

Format with a condition and including a - sign loses the extra - sign: console.log(SSF.format('[<=9999999]###\\-####;\\(###\\)\\ ###\\-####', -12.3)) -12.3 Excel gives `--12.3` (one from the `\-` and one from the negative number). Possibly related, this one is wrong too: console.log(SSF.format('[=0]?;#,##0.00', -12.3)) 12.3 (loses the - sign)
snoopyjc commented 2020-10-05 02:41:14 +00:00 (Migrated from github.com)

This one was difficult!!

Found another bad test case in oddities.json:

  ["[Red]General ;[Blue]General\\ ;[Green]Generalp;[Yellow]General'",
     [50, "50 "],[0,"0p"],[-25,"-25 "],["foo","foo'"]],

should be:

  ["[Red]General ;[Blue]General\\ ;[Green]Generalp;[Yellow]General'",
     [50, "50 "],[0,"0p"],[-25,"25 "],["foo","foo'"]],
This one was difficult!! Found another bad test case in oddities.json: ["[Red]General ;[Blue]General\\ ;[Green]Generalp;[Yellow]General'", [50, "50 "],[0,"0p"],[-25,"-25 "],["foo","foo'"]], should be: ["[Red]General ;[Blue]General\\ ;[Green]Generalp;[Yellow]General'", [50, "50 "],[0,"0p"],[-25,"25 "],["foo","foo'"]],
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#2586
No description provided.