-1

Guys any help I can get here I will appreciate it. I keep getting this error message not sure what's going on. "both Cell type numeric and string cannot be resolved"

          while (cellIterator.hasNext()){
                  final Cell cell = cellIterator.next();
                    switch (cellIndex)
                    {
                        case 0:
                            if(cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
                                newStudent.studentId = (int)cell.getNumericCellValue();
                                cellIndex++;
                            }
                            break;
                            
                        case 1:
                            if(cell.getCellType() == Cell.CELL_TYPE_STRING) {
                                newStudent.major = cell.getStringCellValue();
                                cellIndex++;
                            }else {
                                newStudent.major = null;
                            }
                            break;
                            
                        case 2:
                            if(cell.getCellType() == Cell.CELL_TYPE_STRING) {
                                newStudent.gender = cell.getStringCellValue();
                                cellIndex++;
                            }else {
                                newStudent.gender = null;
                            }
                            break;
                    }
                    
                }
papa
  • 7
  • 1
  • 1
  • 6

2 Answers2

2

Instead of

Cell.CELL_TYPE_STRING
Cell.CELL_TYPE_NUMERIC

Use these:

CellType.STRING
CellType.NUMERIC

Reference link is CellType

Wils Mils
  • 613
  • 4
  • 9
1

I'm not actually familiar with Apache POI, but from the documentation here, it looks like you might need to get CellType.NUMERIC instead of Cell.CELL_TYPE_NUMERIC, and CellType.STRING instead of Cell.CELL_TYPE_STRING?

tensixes
  • 121
  • 1
  • 1
  • 4