[Bug Report]: formatN should not output "0" when no input is provided
See original GitHub issueEnvironment Carbone Version: 2.1.0 Node Version: 10.20.1 Desktop OS: Debian Stretch LibreOffice: 6.1.5.2
Expected Behaviour
null:formatN()
xml output should be an empty string
Actual Behaviour
null:formatN()
output “0”
Steps to reproduce
Try to format null
or undefined
:
null:formatN()
Other comments
Is there a workaround? I am playing with Conditioned output but I can’t make it work.
{$my_number:ifEmpty()} // OK: value is not printed if null
{$my_number:ifEmpty():formatN()} // KO: '0' is printed if null
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Ten simple rules for reporting a bug - PLOS
Rule 2: Check whether the bug is already fixed If you really do need to file a bug against an old version, be...
Read more >How to Report Bugs Effectively - PowerWorld
Anybody who has written software for public use will probably have received at least one bad bug report. Reports that say nothing ("It...
Read more >Reading bug reports | Android Open Source Project
Android bug reports contain dumpsys , dumpstate , and logcat data in text (.txt) format, enabling you to easily search for specific content....
Read more >GCC Bugs - GNU Project
If you report a bug which causes the compiler to print a bug box, include that bug box in your report, and do...
Read more >CWE-20: Improper Input Validation (4.9) - MITRE
When software does not validate input properly, an attacker is able to craft the input in a form that is not expected by...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for your reply.
I switch back to exceljs for complex spreedsheet generation.
But I will give an other try to carboneJS soon in order to provide to my applications users a simple way customize basic non-spreadsheet documents templates.
Hello @Toub, sorry for the delay! After discussing with the team, we got the same problem internally. Our main priority is to improve the XLSX report generation and then we will be able to fix this issue. In the meantime, you can take a look at the preprocessing process where the
formatN
is behaving differently than other formatters for ODS/XLSX files: https://github.com/Ideolys/carbone/blob/37355e9e789320a5d50013ec94be50092e33b9e6/lib/preprocessor.js#L212 If aformatN
formatter is found, the string cell is converted to a number cell. As it is a preprocessing function, this stage doesn’t know if the injected value exists. To fix the issue, the cell conversion should be done during or after the building process.