我用java读取excel,当循环行的时候,根据不同的列,取出不同的值,再进行不同的操作,
如:
  for(Row row : sheet)
 { 
    String s = row.getCell(0).getStringCellValue();
     System.out.println(s+"classes");
    String s = row.getCell(0).getStringCellValue();
    System.out.println(s+"name");  
},但是总是出现如下的错误,java.lang.IllegalStateException: Cannot get a text value from a numeric cell,有哪位高人指点一下,小女子不胜感激,因为我是新来的 ,所以没办法给分,抱歉啊

解决方案 »

  1.   

    strExcelCell = String.valueOf(row.getCell((short) cellNum).getNumericCellValue());
    把numeric类型转为String
      

  2.   

    先判断CELL的文本类型,在用相应的方法取值
      

  3.   

     for(Row row : sheet) 

        int s = row.getCell(0).getNumericCellValue(); 
        System.out.println(s+"classes"); 
        int s = row.getCell(0).getNumericCellValue(); 
        System.out.println(s+"name");  
    }