xzel23 commented on code in PR #321:
URL: https://github.com/apache/poi/pull/321#discussion_r847278871
##########
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:
While I can confirm that Excel displays the value as 2.1, this is obviously
done in the Excel formatter as the value in the XML is stored as
2.0499999999999998:
```
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="x14ac xr xr2 xr3"
xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac"
xmlns:xr="http://schemas.microsoft.com/office/spreadsheetml/2014/revision"
xmlns:xr2="http://schemas.microsoft.com/office/spreadsheetml/2015/revision2"
xmlns:xr3="http://schemas.microsoft.com/office/spreadsheetml/2016/revision3"
xr:uid="{7487740C-7451-9943-A628-9BEEC0E38BD2}">
<dimension ref="A1:A6" />
<sheetViews>
<sheetView tabSelected="1" workbookViewId="0">
<selection activeCell="A6" sqref="A6" />
</sheetView>
</sheetViews>
<sheetFormatPr baseColWidth="10" defaultRowHeight="16"
x14ac:dyDescent="0.2" />
<sheetData>
<row r="1" spans="1:1" x14ac:dyDescent="0.2">
<c r="A1">
<v>2.04</v>
</c>
</row>
<row r="2" spans="1:1" x14ac:dyDescent="0.2">
<c r="A2" s="1">
<v>2.04</v>
</c>
</row>
<row r="3" spans="1:1" x14ac:dyDescent="0.2">
<c r="A3">
<v>2.0499999999999998</v>
</c>
</row>
<row r="4" spans="1:1" x14ac:dyDescent="0.2">
<c r="A4" s="1">
<v>2.0499999999999998</v>
</c>
</row>
<row r="5" spans="1:1" x14ac:dyDescent="0.2">
<c r="A5">
<v>2.06</v>
</c>
</row>
<row r="6" spans="1:1" x14ac:dyDescent="0.2">
<c r="A6" s="1">
<v>2.06</v>
</c>
</row>
</sheetData>
<pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75"
header="0.3" footer="0.3" />
<pageSetup paperSize="9" orientation="portrait" horizontalDpi="0"
verticalDpi="0" />
</worksheet>
```
What should be done is check why the BigDecimal formatter displays this
*wrong* (or in other words: what kind of workaround is implemented there). It
looks like they map everything within one ULP to the rounded value.
--
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]