Reputation: 61
My actual number is : "89148000001958100000" (i.e) Excel column data, After getting data through apahce poi plugin it is converting to 8.91480000019581E+019.
Convertion Code snippet :
import org.apache.poi.ss.usermodel.Cell;
double dd = cell.getNumericCellValue();
How can i achieve my actual number in excel file.
Please suggest...
Upvotes: 2
Views: 3321
Reputation: 219
You can use BigDecimal for this aswell. You can directly return a BigDecimal too or String representation of the large number.
Let's say the cell holds the big value
private String getStringValue(Cell cell)
{
if(cell.getCellType()==CellType.NUMERIC)
{
return new BigDecimal(String.valueOf(cell.getNumericCellValue())).toPlainString();
}
else if(cell.getCellType() == CellType.STRING)
{
return cell.getStringCellValue();
}
return "";
}
Upvotes: 1
Reputation: 61
I got the Solution to converting Scientific notated number to normal number
The code snippet:
NumberFormat formatter = new DecimalFormat("#0");
String opt = formatter.format(value);
This code gives actual number.
Upvotes: 0
Reputation: 545
DataFormatter fmt = new DataFormatter();
String value= fmt.formatCellValue(cell);
You can display the value as it is in excel using DataFormatter
You can also convert String into required format using BigDecimal or BigInteger classes to hold larger values
Upvotes: 2