CELL_TYPE_STRING cannot be resolved or is not a field

后端 未结 3 478
梦谈多话
梦谈多话 2021-02-04 15:05

Stack trace

Exception in thread \"main\" java.lang.Error: Unresolved compilation problems: 
CELL_TYPE_STRING cannot be resolved or is not a field
CELL_TYPE_N         


        
3条回答
  •  独厮守ぢ
    2021-02-04 15:11

    If you're using a later version of Apache POI poi-4.0.1, Cell.getCellType() returns the CellType enum instead of int, so your switch should look like this:

    now in CELL_TYPE_NUMERIC is now just NUMERIC remove CELL_TYPE_

      while(cellitr.hasNext())
                    {
                        Cell celldata=(Cell) cellitr.next();
                        switch(celldata.getCellType())
                        {
                        case STRING:
                            data.add(celldata.getStringCellValue());
                            break;
                        case NUMERIC:
                            data.add(celldata.getNumericCellValue());
                            break;
                        case BOOLEAN:
                            data.add(celldata.getBooleanCellValue());
                            break;
                        }
    

提交回复
热议问题