Selenium Java Data Driven Automation - How to Read Data from Excel File
Step 1 = Create a Maven Project
Step 2 = Add Apache POI dependencies in POM.xml file
Apache POI
Apache POI ooxml
Step 3 - Create an excel file and save it.
Step 4 - Create object of FileInputStream to read the file.
FileInputStream fs = new FileInputStream("F:\\TestData\\SampleData.xlsx");
Step 5 - //Creating a workbook
XSSFWorkbook workbook = new XSSFWorkbook(fs);
Step 6 - //Identify Worksheet in workbook
XSSFSheet sheet = workbook.getSheetAt(1);
Step 7 - //Get the Row from worksheet
Row row = sheet.getRow(0);
Step 8 - //Get the cell from the Row Reference
Cell cell = row.getCell(0);
Step 9 - //Get the value from the cell.
System.out.println(cell.getStringCellValue());
//System.out.println(sheet.getRow(0).getCell(0));
//System.out.println(sheet.getRow(0).getCell(1));
Step 10 - //How to count total columns getLastCellNum()
System.out.println(sheet.getRow(0).getLastCellNum());
Step 11 - //How to count total Rows
System.out.println(sheet.getLastRowNum());
#javaconcepts #javainterviewquestionsanswers #seleniumjava
#datadriven #automationtesting #automationtestinginterviewquestions
#qatraining #letslearnqa
On this page of the site you can watch the video online Selenium Java Data Driven Automation - How to Read Data from Excel File with a duration of hours minute second in good quality, which was uploaded by the user Lets Learn QA 13 February 2026, share the link with friends and acquaintances, this video has already been watched 188 times on youtube and it was liked by 12 viewers. Enjoy your viewing!