Selenium : Read Excel file using JExcel API

Code to read  value from Excel file using selenium WebDriver & Java is as follows -

inputWorkbook = new File("C:\\Controller.xls"); //specify excel file path

    Workbook w;
    try {
            try {

                        w = Workbook.getWorkbook(inputWorkbook);

                        sheet = w.getSheet("Sheet1"); //Worksheet name

                        } catch (IOException e) {
                                    error("Reading Master Sheet :-" +e);
                        suite = new String[sheet.getRows()][sheet.getColumns()];
                        for (int j = 0; j < sheet.getColumns(); j++){
                                    for (int i = 0; i < sheet.getRows(); i++){
                                                Cell cell = sheet.getCell(j, i);
                                                if (cell.getContents()!= null){
Note – Suite[][] is two dimensional array which stores value read from Excel Worksheet.


Popular posts from this blog

Testing Webservice with SoapUI Having Windows Authentication

Data Driven Testing Using Selenium -WebDriver in Python

How to Re-run Failed Scenarios in Cucumber