|
|
Question : Cell formatting - #,###.## leaves a hanging decimal point
|
|
I'm generating an excel spreadsheet from Java using the gnumeric library and I need to format some cells so that whole numbers are presented as having no decimal place while non-whole numbers are displayed to 2 d.p. I'm asking in this forum as I can re-produce this effect directly in excel, so I don't think it's an issue with the way the spreadsheet is generated.
Normally I would just use a format of #,###.## so that 3000.00 and 7000.01 would be formatted as 3000 and 7000.01.
But in excel, this will produce 3000. and 7000.01 (note the hanging decimal point on the 3000). This is the first time I've seen this behaviour, I thought it was standard to remove the decimal point if the trailing digits were zeros.
Unfortunately I can only use simple formatting, not any functions or macros.
Any solutions or suggestions?
|
Answer : Cell formatting - #,###.## leaves a hanging decimal point
|
|
You could test the number in your Java code and, depending on whether it was whole or not, use either #,### or #,###.##.
Kevin
|
|
|
|
|