CELL_TYPE_NUMERIC 无法解析或不是一个字段。

huangapple go评论99阅读模式
英文:

CELL_TYPE_NUMERIC cannot be resolved or is not a field

问题

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;
    }
}
英文:

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;
                    }
                    
                }

答案1

得分: 2

替代原有的代码:

CellType.STRING
CellType.NUMERIC

请参考链接:CellType

英文:

Instead of

Cell.CELL_TYPE_STRING
Cell.CELL_TYPE_NUMERIC

Use these:

CellType.STRING
CellType.NUMERIC

Reference link is CellType

答案2

得分: 1

我实际上对Apache POI不太熟悉,但根据这里的文档,看起来您可能需要使用CellType.NUMERIC代替Cell.CELL_TYPE_NUMERIC,以及使用CellType.STRING代替Cell.CELL_TYPE_STRING

英文:

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?

huangapple
  • 本文由 发表于 2020年7月27日 08:53:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/63107308.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定