Posts

Showing posts from July, 2012

Selenium : Read Excel file using JExcel API

Code to readvalue 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){ suite[i][j]=cell.getContents();                                                 }                                     }