I cannot confirm your observations.
If I have the following Excel:

As you see 5.25976143202331%
in A1
. It is a German Excel
so decimal separator is comma. But that does not matter.
There the XML
is:
<sheetData>
<row r="1" spans="1:1" x14ac:dyDescent="0.25">
<c r="A1" s="1">
<v>5.2597614320233098E-2</v>
</c>
</row>
</sheetData>
And the following code
import org.apache.poi.xssf.usermodel.*;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.format.CellNumberFormatter;
import java.io.*;
import java.math.BigDecimal;
import java.util.Locale;
class ExcelProcentValuePrecision {
public static void main(String[] args) throws Exception{
InputStream inp = new FileInputStream("ExcelProcentValuePrecision.xlsx");
Workbook workbook = WorkbookFactory.create(inp);
Cell cell = workbook.getSheetAt(0).getRow(0).getCell(0);
String s = ((XSSFCell)cell).getCTCell().getV();
System.out.println(s);
BigDecimal bd = new BigDecimal(s);
System.out.println(bd);
double d = cell.getNumericCellValue();
System.out.println(d);
Locale.setDefault(Locale.US);
DataFormatter dataformatter = new DataFormatter();
s = dataformatter.formatCellValue(cell);
System.out.println(s);
CellNumberFormatter formatter = new CellNumberFormatter("#.#################%");
s = formatter.format(cell.getNumericCellValue());
System.out.println(s);
workbook.close();
}
}
leads to:

So 5.2597614320233098E-2
is the value directly out of the XML
. 0.052597614320233098
is that value as an BigDecimal
. 0.0525976143202331
is that value as floating point double
according to IEEE floating point. 5.26%
is that value formatted as displayed in Excel
.
And 5.25976143202331%
is that value as displayed in Excel
's formula bar. Percent values are an exceptional case since there Excel
shows %
format also in formula bar but with fully count of significant digits (up to 15).
That exception with %
values is because %
formatting in Excel
is not only formatting but also changing of the value. 1
= 100%
. So if you put 100%
in an Excel
cell, the value 1
is stored. If you put 10%
in an Excel
cell, the value 0.1
is stored.