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

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

CELL_TYPE_NUMERIC cannot be resolved or is not a field

问题

  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"
  2. while (cellIterator.hasNext()){
  3. final Cell cell = cellIterator.next();
  4. switch (cellIndex)
  5. {
  6. case 0:
  7. if(cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
  8. newStudent.studentId = (int)cell.getNumericCellValue();
  9. cellIndex++;
  10. }
  11. break;
  12. case 1:
  13. if(cell.getCellType() == Cell.CELL_TYPE_STRING) {
  14. newStudent.major = cell.getStringCellValue();
  15. cellIndex++;
  16. }else {
  17. newStudent.major = null;
  18. }
  19. break;
  20. case 2:
  21. if(cell.getCellType() == Cell.CELL_TYPE_STRING) {
  22. newStudent.gender = cell.getStringCellValue();
  23. cellIndex++;
  24. }else {
  25. newStudent.gender = null;
  26. }
  27. break;
  28. }
  29. }
英文:

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"

  1. while (cellIterator.hasNext()){
  2. final Cell cell = cellIterator.next();
  3. switch (cellIndex)
  4. {
  5. case 0:
  6. if(cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
  7. newStudent.studentId = (int)cell.getNumericCellValue();
  8. cellIndex++;
  9. }
  10. break;
  11. case 1:
  12. if(cell.getCellType() == Cell.CELL_TYPE_STRING) {
  13. newStudent.major = cell.getStringCellValue();
  14. cellIndex++;
  15. }else {
  16. newStudent.major = null;
  17. }
  18. break;
  19. case 2:
  20. if(cell.getCellType() == Cell.CELL_TYPE_STRING) {
  21. newStudent.gender = cell.getStringCellValue();
  22. cellIndex++;
  23. }else {
  24. newStudent.gender = null;
  25. }
  26. break;
  27. }
  28. }

答案1

得分: 2

替代原有的代码:

  1. CellType.STRING
  2. CellType.NUMERIC

请参考链接:CellType

英文:

Instead of

  1. Cell.CELL_TYPE_STRING
  2. Cell.CELL_TYPE_NUMERIC

Use these:

  1. CellType.STRING
  2. 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:

确定