Use this following code for reading the values from sheet:

@DataProvider(name = “Rahul”)

public Object[][] readExcel(String sheetName) throws InvalidFormatException, IOException {

//Load the Excel File

File src = new File(“./data/”+sheetName+”.xlsx”);

//Open the Book

XSSFWorkbook wb = new XSSFWorkbook(src);

//Go to Sheet

XSSFSheet sheet = wb.getSheet(“Sheet1”);

//Row Count

int rowCount = sheet.getLastRowNum();

System.out.println(rowCount);

//Column Count

int column = sheet.getRow(0).getLastCellNum();

System.out.println(column);

Object[][] data = new Object[rowCount][column];

// Row – for

for (int i = 1; i <=rowCount; i++) {

XSSFRow row = sheet.getRow(i);

//Column – for

for (int j = 0; j < column; j++) {

XSSFCell cell = row.getCell(j);

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

data[i-1][j] = cell.getStringCellValue();

}

}

return data;

}

}



Source link https://sqa.stackexchange.com/questions/31898/i-am-getting--in-excel--how-can-i--this-error

LEAVE A REPLY

Please enter your comment!
Please enter your name here