Cannot get a text value from a numeric cell.
Used date formatter and it didn't work out.
Converted to string as well. That too didn't work well.
if(isCellEmpty(sheet.getRow(i).getCell(j)))
{
System.out.println("Phone Number field is empty " +i +" " +j +" ================================================>");
break;
}
else {
DataFormatter formatter = new DataFormatter();
Cell cell = sheet.getRow(i).getCell(j);
String pass = formatter.formatCellValue(cell);
Thread.sleep(2000);
/*Cell cell = sheet.getRow(i).getCell(j);
double a=(double) cell.getNumericCellValue();
String n=Double.toString(a);*/
driver.findElement(Appointment.PhoneNumber).sendKeys(pass);
}
What should I do next?
You can try like this
for(int i=0; i<sheet.getLastRowNum(); i++){
Row row =sheet.getRow(i);
for(int j=0; j<row.getLastCellNum(); j++){
Cell cell=row.getCell(j);
if(cell==null){
System.out.println("null cell at row " +i +" cell no "+j);
}
if(cell.getCellType()==Cell.CELL_TYPE_STRING){
System.out.println(cell.getStringCellValue());
}
if(cell.getCellType()==Cell.CELL_TYPE_NUMERIC){
System.out.println(String.valueOf(cell.getNumericCellValue()));
}
if(cell.getCellType()==Cell.CELL_TYPE_BLANK){
System.out.println("blank cell at row " +i +" cell no "+j);
}
}
}
i just printed cell values, if required please catch them into string and can be used in webdriver commands.
Thanks
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.