I am reading from excel file for the below code i am getting exception Cannot get a STRING value from a NUMERIC cell. | Selenium Forum
R
Ramesh Posted on 16/12/2020

 

FileInputStream fs= new FileInputStream("D:\\Test.Xlsx");

XSSFWorkbook wk= new XSSFWorkbook(fs);

XSSFSheet S1 =wk.getSheet("Sheet1");


int r=S1.getPhysicalNumberOfRows();

for(int i=0;i<r;i++)
{
XSSFRow r1=S1.getRow(i);

int c=r1.getPhysicalNumberOfCells();



for(int j=0;j<c;j++)

{

XSSFCell C11=r1.getCell(j);


System.out.println(C11.getStringCellValue());


}

}

 

 

java.lang.IllegalStateException: Cannot get a STRING value from a NUMERIC cell
at org.apache.poi.xssf.usermodel.XSSFCell.typeMismatch(XSSFCell.java:1035)
at org.apache.poi.xssf.usermodel.XSSFCell.getRichStringCellValue(XSSFCell.java:390)
at org.apache.poi.xssf.usermodel.XSSFCell.getStringCellValue(XSSFCell.java:342)
at com.test.GoogleTest.ReadExcel(GoogleTest.java:91)