If you added jars of poi properly then below code is simpler way you can use to read excel
private static XSSFCell Cell;
private static XSSFRow Row;
public static final String Path = System.getProperty("user.dir")+"\\src\\testData\\TestData.xlsx";
public static final String SheetName = "Sheet1";
FileInputStream ExcelFile = new FileInputStream(Path);
// Access the required test data sheet
ExcelWBook = new XSSFWorkbook(ExcelFile);
ExcelWSheet = ExcelWBook.getSheet(SheetName);
Cell = ExcelWSheet.getRow(RowNum).getCell(ColNum);
System.out.println(Cell); //data from specific row
private static XSSFCell Cell;
private static XSSFRow Row;
public static final String Path = System.getProperty("user.dir")+"\\src\\testData\\TestData.xlsx";
public static final String SheetName = "Sheet1";
FileInputStream ExcelFile = new FileInputStream(Path);
// Access the required test data sheet
ExcelWBook = new XSSFWorkbook(ExcelFile);
ExcelWSheet = ExcelWBook.getSheet(SheetName);
Cell = ExcelWSheet.getRow(RowNum).getCell(ColNum);
System.out.println(Cell); //data from specific row
No comments:
Post a Comment