"General;General;-;General" is not working properly. #2566

Open
opened 2020-03-29 16:36:10 +00:00 by BlueSpider929 · 1 comment
BlueSpider929 commented 2020-03-29 16:36:10 +00:00 (Migrated from github.com)

According to the format code structure(positive;negative;zero;text), I expected '-' for zero, but I got 0.

I think the problem here is using General as formatted code for positive section.
When I do not use General syntax for the positive section, I can get the desired result.
I've wrote some code snippets here for better understanding.

On the other hand, this is how Excel works. It is working even if I use General format code for positive section.
image

Could you help me how to figure this problem out?

According to the format code structure(`positive;negative;zero;text`), I expected '-' for zero, but I got 0. I think the problem here is using `General` as formatted code for `positive` section. When I do not use `General` syntax for the `positive` section, I can get the desired result. I've wrote some code snippets [here](https://jsfiddle.net/bluespider929/k10vhdsb/9/) for better understanding. On the other hand, this is how Excel works. It is working even if I use `General` format code for `positive` section. ![image](https://user-images.githubusercontent.com/46532794/77854588-185f2b00-71b9-11ea-968c-581b78a0b19e.png) Could you help me how to figure this problem out?
snoopyjc commented 2020-10-03 20:35:59 +00:00 (Migrated from github.com)

Suggested fix:

// if(isgeneral(sfmt,0)) return general_fmt(v, o);
ov = v;
if(v instanceof Date) v = datenum_local(v, o.date1904);
var f = choose_fmt(sfmt, v);
// if(isgeneral(f[1])) return general_fmt(v, o);
if(isgeneral(f[1])) return general_fmt(ov, o);
Suggested fix: // if(isgeneral(sfmt,0)) return general_fmt(v, o); ov = v; if(v instanceof Date) v = datenum_local(v, o.date1904); var f = choose_fmt(sfmt, v); // if(isgeneral(f[1])) return general_fmt(v, o); if(isgeneral(f[1])) return general_fmt(ov, o);
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#2566
No description provided.