微信小程序选项卡功能开发步骤与方法全解析
1675
2022-11-29
POI cell.setCellType()过时的替代方案
今天用poi开发中遇到一个问题,找了很久找到答案
问题描述
一开始用的是
public static String getValue(Cell cell) { String cellValue = ""; if (cell == null) { return cellValue; } // 把数字当成String来读,避免出现1读成z`1.0的情况 cell.setCellType(CellType.STRING); if (cell.getCellType() == CellType.BOOLEAN) { cellValue = String.valueOf(cell.getBooleanCellValue()); } else if (cell.getCellType() == CellType.NUMERIC) { cellValue = String.valueOf(cell.getNumericCellValue()); } else if (cell.getCellType() == CellType.STRING) { cellValue = String.valueOf(cell.getStringCellValue()); } else if (cell.getCellType() == CellType.FORMULA) { cellValue = String.valueOf(cell.getCellFormula()); } else if (cell.getCellType() == CellType.BLANK) { cellValue = " "; } else if (cell.getCellType() == CellType.ERROR) { cellValue = "非法字符"; } else { cellValue = "未知类型"; } return cellValue; }
这种方法,但是这个中间setCellType()方法过时所以只能找其他方法来代替
显示这个方法过时
搜了一些博客之后,用下面就可以替代
Cell cell = row.getCell(j); DataFormatter dataFormatter = new DataFormatter(); String value = dataFormatter.formatCellValue(cell);
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~