pjfanning commented on code in PR #321:
URL: https://github.com/apache/poi/pull/321#discussion_r847293692


##########
poi/src/main/java/org/apache/poi/ss/usermodel/DataFormatter.java:
##########
@@ -950,7 +950,7 @@ private String getFormattedNumberString(Cell cell, 
ConditionalFormattingEvaluato
         if (numberFormat == null) {
             return String.valueOf(d);
         }
-        String formatted = numberFormat.format(d);
+        String formatted = numberFormat.format(new 
BigDecimal(String.valueOf(d)));

Review Comment:
   String formatted = numberFormat.format(new 
BigDecimal(NumberToTextConverter.toText(d)));
   
   This was the first attempt I made - it fixes this github321 case but breaks 
some existing tests.
   
   That NumberToTextConverter seems to have some logic that mimics how Excel 
takes the 2.0499999999999998 and converts it to 2.05 . If we can find out why 
the other tests break that this solution might be better.
   
   Double.toString also seems to correct for some of these issues to because it 
too converts 2.0499999999999998 to 2.05.
   
   In the end the madness is why do Microsoft store 2.05 as 2.0499999999999998 
in their sheet XML in the first place.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to