public class TestUtil extends TestBase {
TestUtil testUtil;
static Workbook book;
static Sheet sheet;
public void switchToFrame() {
driver.switchTo().frame("mainpanel");
}
public static String TESTDATA_SHEET_PATH = ".\\src\\main\\java\\com\\testData\\FreeCRMTestData.xlsx";
public static Object[][] getTestData(String sheetName) {
FileInputStream file = null;
try {
file = new FileInputStream(TESTDATA_SHEET_PATH);
} catch (Exception e) {
e.printStackTrace();
}
try {
book = WorkbookFactory.create(file);
} catch (Exception e) {
e.printStackTrace();
}
// Get the Sheet.
sheet = book.getSheet(sheetName);
//getLastRowNum() Gets the number last row on the sheet.
//getLastCellNum() Gets the index of the last cell contained in this row PLUS ONE.
Object[][] data = new Object[sheet.getLastRowNum()][sheet.getRow(0).getLastCellNum()];
for (int i = 0; i < sheet.getLastRowNum(); i++) {
for (int k = 0; k < sheet.getRow(0).getLastCellNum(); k++) {
data[i][k] = sheet.getRow(i + 1).getCell(k).toString();
}
}
return data;
}
}
Description:- I want to read an Excel file from Java with X columns and Y rows. What does the statement Object[][] data = new Object [][] mean? Can anyone give me simple comments for the whole code snippet?