I am using ExcelJS library with Flexmonster to export my Pivot Table to Excel. I noticed that when I set the decimalPlaces value in format options and export the report the actual value is exported with a numberFormat applied. I wanted the values to be exported with the remaining numbers truncated and not be present in my exported excel. I tried doing this through customizeCellFunction where I forcefully truncated the values using the toFixed method but that had a weird issue where it didn't work for numbers less than 1000. Please help me fix this.
I can understand that the FormatObject is present only for changing the number format and not change the actual value but atleast modifying the values through customizeCell should be consistent for all values
Hello, Amogh!
Thank you for reaching out to us.
The described functionality for truncating the numbers can be achieved with Flexmonster's Excel export. Moreover, the decimalPlaces
parameter rounds numbers similarly to the toFixed
method, as is shown in this example: https://jsfiddle.net/flexmonster/0p5L48xv/
If this approach for number formatting does not work for you, could you please modify the JSFiddle to reproduce the issue or provide more details about your case?
Looking forward to hearing from you.
Best Regards,
Maksym
Hello Maksym,
What I meant when I said that numbers are not actually getting truncated is that the entire value is still available when exported to excel (just a number formatting is applied but if you edit the value it still has all the decimal places). I have shared a screenshot to show what I mean.
Using customizeCell like this: https://jsfiddle.net/fgza5mw9/11/ also didn't work. I am able to truncate the values after they've been added to the worksheet through ExcelJS but I don't have the context of whether a value is a currency, number or percent datatype so I'm not able to have different decimal places for them so ideally it should be possible through customizeCell.