You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2022/02/18 03:30:30 UTC
[Bug 65897] New: Reading large number in Excel, precision lost
https://bz.apache.org/bugzilla/show_bug.cgi?id=65897
Bug ID: 65897
Summary: Reading large number in Excel, precision lost
Product: POI
Version: unspecified
Hardware: PC
Status: NEW
Severity: normal
Priority: P2
Component: XSSF
Assignee: dev@poi.apache.org
Reporter: vosamo@outlook.com
Target Milestone: ---
When I tried to read very large number in excel,i found the number lost
precision.For example,the number in my excel is '100283710028672000000',i used
poi open the excel file and read the number,but it became
'100283710028672010000'.But no problem with '100283710028673000000' or
'100283710028674000000' or some other numbers.I don't know why.Can you help me?
My code as below:
============================
public static void main(String[] args) throws IOException {
NumberFormat numberFormat = NumberFormat.getInstance( );
numberFormat.setGroupingUsed(false);
String filePath = "D:\\work\\test\\test.xlsx";
InputStream is = new FileInputStream(filePath);
XSSFWorkbook wb = new XSSFWorkbook(is);
XSSFSheet sheet = wb.getSheetAt(0);
Row row = sheet.getRow(0);
Cell cell = row.getCell(0);
String val = numberFormat.format(cell.getNumericCellValue());
BigDecimal b = new BigDecimal(val);
System.out.println(b);
}
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 65897] Reading large number in Excel, precision lost
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=65897
PJ Fanning <fa...@yahoo.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
OS| |All
--- Comment #1 from PJ Fanning <fa...@yahoo.com> ---
Please read
https://stackoverflow.com/questions/41067328/apache-poi-not-returning-the-proper-value-for-large-numbers-coming-from-excel/41106535
I work around this issue by using
https://poi.apache.org/apidocs/dev/org/apache/poi/ss/usermodel/DataFormatter.html#formatCellValue-org.apache.poi.ss.usermodel.Cell-
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 65897] Reading large number in Excel, precision lost
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=65897
PJ Fanning <fa...@yahoo.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |INFORMATIONPROVIDED
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 65897] Reading large number in Excel, precision lost
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=65897
--- Comment #2 from PJ Fanning <fa...@yahoo.com> ---
https://poi.apache.org/apidocs/dev/org/apache/poi/ss/util/NumberToTextConverter.html
is also useful
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org