关于java读取Excel读出的数据避免科学计数法
作者:
demil | 来源:发表于
2016-03-30 17:48 被阅读1459次
if(row.getCell(j).getCellType() == Cell.CELL_TYPE_NUMERIC)
{
DecimalFormat df = new DecimalFormat("0");
value = df.format(row.getCell(j).getNumericCellValue());
value = subZeroAndDot(value);
}
/** * 使用正则表达式去掉多余的.与
* * @param s
* @return
*/
private String subZeroAndDot(String s) {
if (s.indexOf(".0") > 0) {
// 去掉多余的
s = s.replaceAll("0+?$", "");
// 如果最后一位是.则去掉
s = s.replaceAll("[.]$", "");
}
return s;
}
本文标题:关于java读取Excel读出的数据避免科学计数法
本文链接:https://www.haomeiwen.com/subject/pccelttx.html
网友评论