56317
2014-03-26 09:05:45 +0000
While reading excel (.xls) numeric value "0.002877" and its multipes of 2 & 4 and division of 3 it shows 19 decimals insted of 6.
2014-03-26 09:51:49 +0000
1
1
1
Unclassified
POI
HSSF
unspecified
PC
Windows XP
RESOLVED
INVALID
P2
critical
---
1
kbenny
dev
0
oldest_to_newest
174095
0
kbenny
2014-03-26 09:05:45 +0000
The following apache packages used;
--------------
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.hssf.usermodel.*;
import org.apache.log4j.*;
--------------
int lengthBeforeDecimal = decimalVal.substring(0,decimalPos).length();
//System.out.println("lengthh before decimal:::"+lengthBeforeDecimal);
//System.out.println("Length after decimal:::"+(actualLength-lengthBeforeDecimal-1));
lengthAfterDec=actualLength-lengthBeforeDecimal-1;
The above code is getting 19 decimals for the numeric value: "0.002877" and its multiples of 2 & 4(0.005754, 0.011508) and division by 3(0.000959).
i.e.; for example: "0.002877" is taken as ".0028770000000000002".
Could you please suggest so that only the six decimals are to be read from the xl-sheet.
Thanks & Regards,
Benny J. Kelambeth
174097
1
apache
2014-03-26 09:40:55 +0000
That's just how floating point values work
If you want to format a cell as a string, as it looks in Excel, use DataFormatter.formatCellValue(Cell)
174098
2
kbenny
2014-03-26 09:51:49 +0000
Hi,
The issue is that only few of the excel (.xls file) numeric value like: "0.002877", is reading as 19 decimals; how ever if we change the last decimal value like 0.002876 or 0.002878 then it is returning as 6 decimals only.
How can we read the following values as 6 decimals.
0.002877
0.005754
0.011508
0.000959
...........
Thanks,
Benny