POI取消科学计数法

时间:2023-03-09 20:16:26
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()));

转自:http://free9277.blog.163.com/blog/static/11641721220111127111239951/