poi 取消科学计数法

阅读更多


前台输入手机号13777777777,如果是为Double类型接收,就会自动转为科学计数法

 

找了下,一般是Double转String,方法一般有两种:

1.利用String.format()

saleUnilateImport.setPhone(String.format("%.4f",row.getCell(1).getNumericCellValue()));//15145117218.0000保留4位小数

String.format("%.0f", row.getCell(0).getNumericCellValue())//15145117218,取整!

 

2.利用DecimalFormat类

DecimalFormat df = new DecimalFormat("#");//转换成整型

saleUnilateImport.setPhone(df.format(row.getCell(1).getNumericCellValue()));

 

3.利用DecimalFormat类

DecimalFormat df = new DecimalFormat("#,##0.00");//保留两位小数且不用科学计数法

saleUnilateImport.setPhone(df.format(row.getCell(1).getNumericCellValue()));

你可能感兴趣的:(poi,科学计数法)