//poi数据类型处理
try {//WorkbookFactory兼容HSSF(2003)和XSSF(2007)
Workbook wb = WorkbookFactory.create(new FileInputStream(new File("D:\\测试.xlsx")));
Sheet sheet = wb.getSheetAt(0);
Row row = sheet.getRow(0);
Cell cell = row.getCell(0);
cell.setCellType(Cell.CELL_TYPE_STRING);
String phone = cell.getStringCellValue();
Cell cell2=row.getCell(1);
cell2.setCellType(Cell.CELL_TYPE_NUMERIC);
Double d = cell2.getNumericCellValue();
d = d*100;
System.out.println("double*:"+d.toString());
BigDecimal b = new BigDecimal(d);
b = b.multiply(new BigDecimal(100));
System.out.println("bigDecimal*:"+b.toString());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
POI读写数据 兼容HSSF和XSSF
最新推荐文章于 2022-12-29 16:50:01 发布