Problem I'm facing is libraries are not imported like Workbook
, Row
, Cell
, HSSFWork
etc. When i try to import its not importing.
Here is link of console: https://prnt.sc/15oajs9
public class ReusableFunction {
WebDriver driver;
public String [][] fetchDataFromExcel() {
Workbook wb = null;
String [][] data= null;
try {
String path = fetchprop("KEYWORD_PATH");
File excel = new File(path);
FileInputStream file = new FileInputStream(excel);
System.out.println(path);
String extn = path.substring(path.indexOf(".")+ 1);
System.out.println(extn);
if (extn.equals("xlsx")) {
wb = new XSSFWorkbook(file);
} else {
wb = new HSSFWorkbook(file);
}
Sheet sheet = wb.getSheet("Sheet1");
int rownum = sheet.getLastRowNum();
System.out.println("Rows: " + rownum);
int column = sheet.getRow(0).getLastCellNum();
data = new String [rownum][column];
for (int i =0; i < rownum; i++) {
Row row = sheet.getRow(i);
for (int j =0; j < column; j++) {
Cell cell = row.getCell(j);
String value = cell.toString();
data[i][j] = value;
}
}
} catch (Exception ex) {
ex.printStackTrace();
} finally {
try {
wb.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return data;
}`
Can anyone have idea how we can solve this problem