从Java中的Excel中获取值的问题

我能够从excel工作表中获取值,我有我的工作表中的第7和第8列datetypes单元格像2015年3月7日20列,我能够正确获取string/文本值,但无法获取date格式的单元格,并得到一个错误,我试着改变types来获取单元格的值,但没有发生,谁能帮我我怎样才能在我的while循环中获得文本/string或date格式单元格'

我的代码如下,

while (iterator.hasNext()) { Row nextRow = iterator.next(); Map<Field, String> values = new EnumMap(Field.class); for (Field f : Field.values()) { Cell cell = nextRow.getCell(f.ordinal()); if (cell != null) { values.put(f, cell.getStringCellValue()); } } 

date格式是2015年3月7日

尝试检查单元格的格式,然后提取正确的function值,

以供参考,

 if(cell.getCellType()==Cell.CELL_TYPE_NUMERIC){ if (DateUtil.isCellDateFormatted(cell)) { System.out.println(cell.getDateCellValue()); } else { System.out.println(cell.getNumericCellValue()); } }