我的实际数字是:“89148000001958100000”(即)Excel列数据,通过apahce poi插件获取数据后,它将转换为8.91480000019581E + 019。
转换代码段:
import org.apache.poi.ss.usermodel.Cell;
double dd = cell.getNumericCellValue();
如何在excel文件中实现我的实际数字。
请建议......
答案 0 :(得分:1)
DataFormatter fmt = new DataFormatter();
String value= fmt.formatCellValue(cell);
您可以使用DataFormatter
在excel中显示该值您还可以使用BigDecimal或BigInteger类将String转换为所需格式以保存更大的值
答案 1 :(得分:1)
我得到了将科学标注号码转换为正常号码的解决方案
代码段:
NumberFormat formatter = new DecimalFormat("#0");
String opt = formatter.format(value);
此代码给出实际数字。
答案 2 :(得分:0)
您也可以为此使用BigDecimal。您也可以直接返回BigDecimal或大数字的String表示形式。
假设单元格具有很大的价值
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 "";
}