Not getting any data from fileinput stream

Currently exploring apache poi and what seems to be the error? I didn't get any value from my filesheets.

Tried to prompt out the value from line 51 and I didn't get any.

This is what I'm doing: I identify test cases column by scanning the entire 1st row and once column is identified then scan entire testcase column to identify purchase testcase row after you grabbing purchase testcase row = I want to pull all the data of that row and feed into test

For the excel file

TIA

enter image description here

Code:

public class App {

    public ArrayList<String> getData(String testcaseName) throws IOException
    {

        ArrayList<String> a=new ArrayList<String>();

        FileInputStream fis=new FileInputStream("/Users/jaxethhugomahiya/Downloads/testData.xlsx");
        XSSFWorkbook workbook=new XSSFWorkbook(fis);

        int sheets=workbook.getNumberOfSheets();
        for(int i=0;i<sheets;i++)
        {
            if(workbook.getSheetName(i).equalsIgnoreCase("testdata"))
            {
                XSSFSheet sheet=workbook.getSheetAt(i);


                Iterator<Row>  rows= sheet.iterator();// sheet is collection of rows
                Row firstrow= rows.next();
                Iterator<Cell> ce=firstrow.cellIterator();//row is collection of cells
                int k=0;
                int column = 0;
                while(ce.hasNext())
                {
                    Cell value=ce.next();

                    if(value.getStringCellValue().equalsIgnoreCase("Testcases"))
                    {
                        column=k;
                    }

                    k++;
                }
                System.out.println(column);


                while(rows.hasNext())
                {
                    Row r=rows.next();
if(r.getCell(column).getStringCellValue().equalsIgnoreCase(testcaseName))
                    {
                        Iterator<Cell>  cv=r.cellIterator();
                        while(cv.hasNext())
                        {
                            Cell c= cv.next();
                            if(c.getCellType()==CellType.STRING)
                            {

                                a.add(c.getStringCellValue());
                            }
                            else{
 a.add(NumberToTextConverter.toText(c.getNumericCellValue()));

                            }
                        }
                    }
                }
            }
        }
        return a;

    }

testSample.java

public static void main(String args) throws IOException{
    App a = new App();
    ArrayList<String> data = a.getData("Add Profile");
    System.out.println(data.get(0));
    System.out.println(data.get(1));
    System.out.println(data.get(2));
    System.out.println(data.get(3));
}

The output:

enter image description here


Solution 1:

Same under app, successfully read the excel file. Thank you

 public static void main(String[] args) throws IOException {
        App a = new App();
        ArrayList data = a.getData("Delete Profile");
        System.out.print(" "+data.get(0));
        System.out.print(" "+data.get(1));
        System.out.print(" "+data.get(2));
        System.out.print(" "+data.get(3));
    }