我正在使用org.apache.poi 3.15讀取excel文件。
這是我的代碼:try (FileInputStream fileInputStream = new FileInputStream(file); XSSFWorkbook workbook = new XSSFWorkbook(file)) {
XSSFSheet sheet = workbook.getSheetAt(0);
Iterator rowIterator = sheet.iterator();
while (rowIterator.hasNext()) {
Row row = rowIterator.next();
Iterator 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 ()已經過時。