Apache POI reads numeric Excel cells as Java double values—not arbitrary-precision decimals. And if Excel has already rounded a number beyond its 15-significant-digit limit, POI cannot recover the missing digits. Choose the reading method based on whether you need a value for arithmetic, the text Excel displays, or an identifier that should never have been numeric.
Why POI can appear to change an Excel number
For a numeric cell, Apache POI’s Cell.getNumericCellValue() returns a Java double. The POI Cell API documents the return type as double; it is not an arbitrary-precision decimal. Formula and error cells return their precalculated numeric value through this method, while calling it on a string cell throws IllegalStateException.
There are two distinct precision boundaries to consider. First, Java’s double is a binary floating-point type, so it may not represent every decimal fraction exactly. Second—and often more consequential for long digit sequences—Excel itself supports at most 15 significant digits in numeric values. Microsoft says digits beyond the fifteenth in a number with 16 or more digits are rounded down to zero; see its guidance on leading zeros and large numbers.
If Excel discarded digits when it stored the cell, converting POI’s result to BigDecimal cannot restore them. BigDecimal.valueOf(double) can represent a decimal form of the double POI returned; that is not necessarily the original decimal entered or imported into Excel.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problems#1 Best Overall
Choose the API for the result you actually need
| Requirement | Approach | Important limitation |
|---|---|---|
| Numeric computation | Read a numeric cell with getNumericCellValue() and handle the result as a double. |
Use an explicit rounding or scale policy if the domain requires one; this does not recover digits Excel has discarded. |
| Text as Excel would display it | Use DataFormatter.formatCellValue(cell). |
It formats the value for display; it does not expose hidden precision. Formula results require a FormulaEvaluator if they must be evaluated rather than using the cached result. |
| Long identifier or code | Store the cell as text in Excel before entry or import, then read it as text. | Changing a rounded numeric cell to text afterward does not restore lost digits. |
| Exact decimal arithmetic | Use a controlled decimal string or a documented scale and rounding rule where the source value is sufficiently intact. | Wrapping a previously read double in BigDecimal alone is not a precision-recovery method. |
When to use DataFormatter
Use POI’s DataFormatter when the requirement is the cell’s formatted text, rather than a raw number for calculation. It returns a String formatted according to the cell’s Excel number format, which can represent items such as currency, percentages, dates, phone numbers, Social Security numbers, or ZIP codes. See the DataFormatter API.
For a formula cell, provide a FormulaEvaluator to formatCellValue when you need POI to evaluate the formula for display. Without one, the formatter does not evaluate formulas. Formatting is still only presentation: POI’s current implementation obtains numeric data through getNumericCellValue() and may use BigDecimal.valueOf(d) while formatting it. That implementation detail does not promise arbitrary-precision storage or restore digits missing from the workbook. See the POI DataFormatter implementation.
Rank #2
Why a displayed number can differ from the value used in calculations
An Excel number format changes how a value looks, not the value stored in the cell. Microsoft explains that Excel normally calculates using stored values, so a cell displayed as currency with two decimal places can retain additional fractional precision that affects formulas. See Microsoft’s explanation of rounding precision.
Scientific notation alone does not prove that a value is corrupted. It may simply be how a number is displayed. To diagnose a mismatch, check the cell’s type, number format, whether it contains a formula, and whether the value is a quantity or an identifier. If you need the displayed form, use a formatter; if you need arithmetic, inspect the numeric value and apply the appropriate calculation policy.
Recommended Free Tools
Rank #3
Preserve identifiers and leading zeros before Excel changes them
Account numbers, SKUs, phone numbers, ZIP codes, and credit-card-like codes are labels, not quantities. They may contain leading zeros or more digits than Excel can preserve in a numeric cell. Microsoft recommends storing long numbers that are identifiers as text. Set the cells or import column to Text before the data is entered or imported, then read the text in POI. A number format can make a value look padded with zeros, but it does not turn the underlying numeric value into an identifier string.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Apply rounding deliberately in Excel
If the goal is to control calculation precision, use an explicit rounding policy such as an appropriate ROUND formula and define the scale and rounding rule for the application. Excel also has a “Set precision as displayed” workbook option, but Microsoft warns that enabling it permanently changes stored values and can accumulate inaccuracies. Treat it as a deliberate workbook-wide data decision, not a harmless display preference; details are in Microsoft’s rounding precision guidance.
Quick Recap
Best Value
Rank #4
A quick diagnostic before changing your code
- Is the cell numeric or text?
getNumericCellValue()is for numeric values; calling it on a string cell throwsIllegalStateException. - Do you need arithmetic or display text? Use the numeric API for calculations and
DataFormatterfor Excel-style display. - Is the cell a formula? Decide whether to use its cached result or evaluate it with a
FormulaEvaluatorfor formatted output. - Is it an identifier? Keep it as text from entry or import, especially if leading zeros or more than 15 significant digits matter.
- Did Excel already round it? If so, no POI conversion or Java decimal wrapper can reconstruct the discarded digits.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

