Getting error Cannot get a text value from numeric cell | Selenium Forum
M
Posted on 02/02/2017
I AM WORKING ON A LIVE PROJECT -- needs to be delivered soon ---Kindly help !!!!
I don't have time to write some complex excel code so I wrote my own basic code to extract data which works good but I should also be able to read
numeric values form the excel sheet
right now I am just using c.getStringCellValue();


I think I have some numeric values in my test data sheet and the excel code that I am using is not reading values form a number cell(Please check the image

@DataProvider(name="negativeRegistration")
public Object[][] negregistrationdata() throws Throwable
{
{
InputStream f = new FileInputStream(CONFIG.getProperty("DataSheet1_Path"));
Workbook wb = WorkbookFactory.create(f);
Sheet s =wb.getSheet("NRegData");
int rowcount = s.getLastRowNum();
r = s.getRow(0);
int cellno = r.getLastCellNum();
//System.out.println(rowcount);
Object data [][] = new Object[rowcount][cellno];
for (int i = 1; i<=rowcount;i++)
{
Row r = s.getRow(i);
for(int j= 0;j<cellno;j++)
{
Cell c = r.getCell(j);
data[i-1][j] = c.getStringCellValue();
}
}
return data;
}
}

M
Replied on 02/02/2017

xls_reader.java cannot handle numbers.

you have to convert numbers into text in excel file.

that can be done by putting [color=#FF0000:ebjwbnlu]' [/color:ebjwbnlu]before the number.

example
[color=#FF0000:ebjwbnlu]'34235[/color:ebjwbnlu]


M
Replied on 07/02/2017

Thank you Responsive image