I am creating excel sheet using apache poi. I have numbers like – 337499.939437217, which I want to show as it is in excel without rounding off. Also the cell format should be number (for some columns) and currency (for some columns).
Please suggest which BuiltinFormats should I use to achieve this.
Many thanks for the help.
Best Answer
At first you need to know how to use DataFormats. Then you need to know the guidelines for customizing a number format.
For your number
-337499.939437217
which will be displayed rounded with general number format, you could use format#.###############
. The#
means a digit which will be displayed only if needed (is not leading zero and/or is not zero as last decimal digit) - see guidelines. So the whole format means show up to 15 decimal digits if needed but only as much as needed.For currency you should really using a built in number format for currency. So the currency symbol depends on the locale settings of
Excel
. The following BuiltinFormats are usable withapache poi
. Using a built in number format you need only the hexadecimal format numbers.Example: