关于读取数字时科学技术法的强制解除

来源:互联网 发布:c语言 pointer 编辑:程序博客网 时间:2024/04/30 19:38

有时从Excel文件中取出的数据太大,java会自动使用科学计数法显示,不符要求,这时就要强制不使用科学计数法,解决办法为:

(1) HSSFRow row = sheet.getRow(1);
HSSFCell cell = row.getCell((short) 3); //该单元格记录的是一个手机号码
DecimalFormat formatter = new DecimalFormat("######");
String s = formatter.format(cell.getNumericCellValue());
System.out.println("Read Numberic: " + s);

(2) HSSFRow row = sheet.getRow(1);
HSSFCell cell = row.getCell((short) 3); //该单元格记录的是一个手机号码

DecimalFormat format = (DecimalFormat) NumberFormat.getPercentInstance();
format.applyPattern("####0");
double strCell = cell.getNumericCellValue();
String temp = format.format(strCell);
System.out.println("Read Number: " + temp);

Technorati : poi number

Powered by Zoundry

原创粉丝点击