我正在使用org.apache.poi 3.15读取excel文件(文件扩展名xlsx).
这是我的代码:
try (FileInputStream fileInputStream = new FileInputStream(file); XSSFWorkbook workbook = new XSSFWorkbook(file)) { XSSFSheet sheet = workbook.getSheetAt(0); Iterator<Row> rowIterator = sheet.iterator(); while (rowIterator.hasNext()) { Row row = rowIterator.next(); Iterator<Cell> cellIterator = row.cellIterator(); while (cellIterator.hasNext()) { Cell cell = cellIterator.next(); switch (cell.getCellType()) { case Cell.CELL_TYPE_NUMERIC: System.out.print(cell.getNumericCellValue() + "(Integer)\t"); break; case Cell.CELL_TYPE_STRING: System.out.print(cell.getStringCellValue() + "(String)\t"); break; } } System.out.println(""); } } catch (Exception e) { e.printStackTrace(); }
我收到一个警告,表示已经弃用了cell.getCellType().有人可以告诉我替代方法吗?