title: getting data by column name apache poi excel
body: <p>I am using apache POI for excel import and parsing . 
  I have to get the data by passing column name .</p>
  
  <p>this is my code</p>
  
  <pre><code>JSONObject jo = new JSONObject();
          JSONArray dataCollection = new JSONArray();
          JSONObject data = null;
          try {
              String tempCampaignFilesPath = getSessionData("userPath") + System.getProperty("file.separator") + "tempCampaignFiles";
              File someFile = new File(tempCampaignFilesPath, fileName);
  
              /* read from this file */
  
              FileInputStream fileInputStream = new FileInputStream(someFile);
              HSSFWorkbook workbook = new HSSFWorkbook(fileInputStream);
              HSSFSheet sheet = workbook.getSheet(sheetName);
              int rowNum = sheet.getLastRowNum() + 1;
              int colNum = sheet.getRow(0).getLastCellNum();
              Row row = null;
              Cell cell = null;
  
              for (int i = 1; i &lt; rowNum; i++) {
                  row = sheet.getRow(i);
                  data = new JSONObject();
  
                  for (int j = 0; j &lt; colNum; j++) {
                      cell = row.getCell(j);
                      data.put(columnList.get(j), cellToString(cell));
                  }
                  dataCollection.put(data);
              }
              fileInputStream.close();
              // someFile.delete();
              jo.put("tableData", dataCollection);
          } catch (Exception e) {
              e.printStackTrace();
          }
          return jo;
  </code></pre>
  
  <p>There is a provision for column index but how could I do it by column name.</p>
  
  <p>Please help me.</p>