Read data from Excel sheet using java

import java.io.FileInputStream;

import org.apache.poi.xssf.usermodel.XSSFRow;

import org.apache.poi.xssf.usermodel.XSSFSheet;

import org.apache.poi.xssf.usermodel.XSSFWorkbook;

class Main {

    public static void main(String[] args) {

// ReadFile

FileInputStream file = new FileInputStream(GlobalPath.DataFilePath);

                             @SuppressWarnings("resource")

XSSFWorkbook wb = new XSSFWorkbook(file);

                             XSSFSheet sheet = wb.getSheet("Statuses");

                             int rowcount = sheet.getLastRowNum();

                             WebElement rowCount = driver.findElement(CaseStatusDropdown);

                             Select sel = new Select(rowCount);

                             int count_of_options = sel.getOptions().size();

                             int FinalCount = count_of_options - 1;

                             System.out.println("The total no. of selectable options in the dropdown menu are =" + count_of_options);

                             ArrayList ExpectedStatus = new ArrayList();

                             //col no of sheet

                             int ColNo = Integer.valueOf(col);

                             System.out.println("Col:" + ColNo + " " + rowcount);

                            

                             for (int i = 1; i <= FinalCount; i++) {

                                           XSSFRow celldata = sheet.getRow(i);

                                           String value = celldata.getCell(ColNo).getStringCellValue().trim().replace(" ", "");

                                           System.out.println(value);

                                           ExpectedStatus.add(value);

                             }

 }

Comments

Popular Posts