title: How to iterate over columns to get row labeled data in Excel?
body: <p>I am writing a Java program in which I want to retrieve data which has row headers. My Excel sheet looks like below:</p>
  
  <p><a href="https://i.stack.imgur.com/FF3nc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FF3nc.png" alt="enter image description here"></a></p>
  
  <p>I have written a following simple Java code to retrieve values sequentially based on row headers:</p>
  
  <pre><code>....
  try
      {
      fileSystem = new POIFSFileSystem (inpStrm);
  
      HSSFWorkbook      workBook = new HSSFWorkbook (fileSystem);
      HSSFSheet         sheet    = workBook.getSheetAt(0);
      int column = 1;
      for(int i = 0;i &lt;=3;i++){
  
          for(int j = 0;j&lt;=3;j++){
              HSSFRow row = sheet.getRow(j);
              System.out.print(row.getCell(column).getStringCellValue() + "    ");
          }
          System.out.println("");
          column++;
      }
      }
      catch(Exception e){
          e.printStackTrace();
      }
  ....
  </code></pre>
  
  <p>And after running code my output comes like below:</p>
  
  <pre><code>P1    M    C1    Hyderabad    
  P2    M    C2    Pune    
  P3    F    C3    Pune    
  P4    M    C4    Hyderabad 
  </code></pre>
  
  <p>Now is there any easy and feasible way to do the same for large Excel sheets (50 row headers)?  </p>
  
  <p>If I use the POGO class having above four properties then how can I get list of objects with values from Excel?  </p>