用getCellType()得到类型
是2,则为日期getCellFormula
是3为数值getNumericCellValue

解决方案 »

  1.   

    static int CELL_TYPE_BLANK 
              Blank Cell type (3) 
    static int CELL_TYPE_BOOLEAN 
              Boolean Cell type (4) 
    static int CELL_TYPE_ERROR 
              Error Cell type (5) 
    static int CELL_TYPE_FORMULA 
              Formula Cell type (2) 
    static int CELL_TYPE_NUMERIC 
              Numeric Cell type (0) 
    static int CELL_TYPE_STRING 
              String Cell type (1) 
    static short ENCODING_COMPRESSED_UNICODE 
                
    static short ENCODING_UTF_16 
                
    这位老大,你说得好像不对啊,上面是poi自己的api,Formula类型就代表是日期吗?照上面api的说法数值型应该是0啊利用poi1.8里面的一个判断方法,我已经成功解决了这个问题,如下:
        int cellType = cell.getCellType();
        if(cellType==cell.CELL_TYPE_NUMERIC){
          if(isCellDateFormatted(cell)){
            cellValue = toWholeFormat(cell.getDateCellValue());
          }else{
            cellValue = String.valueOf((long)cell.getNumericCellValue());
          }
        }else if(cellType==cell.CELL_TYPE_STRING){
          cellValue = cell.getStringCellValue();
        }else{
          cellValue = cell.getStringCellValue();
        }