Java:无法从Excel单元格读取日期

时间:2018-10-18 13:04:35

标签: java excel date apache-poi

我有一个excel工作表,它在单元格D3中包含一个日期,该“ D3”作为值在其他某个单元格中给出。我尝试通过单元格引用访问此日期,但是却得到了一个奇怪的数字。

下面是我的代码:

    case Cell.CELL_TYPE_FORMULA: 
       switch(cell.getCachedFormulaResultType()) { 
       case Cell.CELL_TYPE_NUMERIC: 
          if (DateUtil.isCellDateFormatted(cell)) { 
             if(formatter.formatCellValue(cell).equalsIgnoreCase("D3")){
                CellReference ref=new CellReference(formatter.formatCellValue(cell)); 
                Row r = sheet.getRow(ref.getRow()); 
                Cell c = r.getCell(ref.getCol()); 
                sb.append("\"" + c.getNumericCellValue()+ "\""); 
             } 
          } 
          break;
       case Cell.CELL_TYPE_STRING:
          sb.append("\"" + cell.getRichStringCellValue()+ "\""); 
          break;
       default:
          break;
       }

我的脚本输出:4334。为什么会这样?

0 个答案:

没有答案
相关问题