New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conditional format unexpected turn negative number to positive #2594
Comments
General works though |
The format has 2 parts. Normally, without a conditional, the second part handles negative values. As an example, using the format The conditionals are actually weird here and need a rethink. In specific, suppose the value is -2. Using the format @snoopyjc any thoughts? |
Yes this is a very complex area of Excel. I have this working in my python version:
@SheetJSDev If you want to back-port it to JS, look at the last block of code in |
Same problem: >>> ssf.format('[>=-1]0;0', -2)
'-2' According to Excel 2019 for Mac and Excel 2019 for Windows, using the format There's no UI chicanery, as an XLSX file with the format has the following representation in the XML: <numFmt numFmtId="170" formatCode="[>=-1]0;0"/> |
Thanks! I will fix it and add more test cases.
…-joe
Sent from my AT&T iPhone
On Oct 8, 2020, at 3:26 AM, SheetJSDev ***@***.***> wrote:
Same problem:
>>> ssf.format('[>=-1]0;0', -2)
'-2'
According to Excel 2019 for Mac and Excel 2019 for Windows, using the format [>=-1]0;0, -2 is rendered as "2" (no negative sign)
There's no UI chicanery, as an XLSX file with the format has the following representation in the XML:
<numFmt numFmtId="170" formatCode="[>=-1]0;0"/>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Any update for the fix? |
Negative number is wrongly formatted to positive number in a condition format
Format:
[>=1000000]#,,\" M\";####.00
Value:
-12.3
Actual:
12.3
Expected:
-12.3
Sample Program
console.log(`${value} => ${X.SSF.format([>=1000000]#,," M";####.00, -12.3)}\t\t format: ${format}``)
Seems negative value is A) converted to positive at https://github.com/SheetJS/sheetjs/blob/master/xlsx.js#L1012 but B) not converted back at https://github.com/SheetJS/sheetjs/blob/master/xlsx.js#L1062
The latter expects a format of 'n?' which I don't quite understand
The text was updated successfully, but these errors were encountered: