title: How to store values from excel to some collection in java
body: <p>i have a excel file like the following,</p>
  
  <pre><code>**Method Name**            **Status Code**     **user**    **password**
  getLoggedinUserDetails        400              anto          test
  createRequisition             400              mayank       hexgen
  excelMDM                      400              xxxxx        hexgen
  createOrder                   400              yyyyy        hexgen
  confirmOrder                  400              zzzzz        hexgen
  </code></pre>
  
  <p>i want to save the above details in some <code>collection</code> so that i can access <code>details by providing username and get the details like Method Name, Status code,and password.</code></p>
  
  <p>i tried some thing like this and able to store only <code>method name and status code</code></p>
  
  <pre><code>package com.hexgen.tools;
  
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.FileNotFoundException;
  import java.io.IOException;
  import java.util.Iterator;
  import java.util.LinkedHashMap;
  import java.util.Map;
  
  import org.apache.poi.hssf.usermodel.HSSFSheet;
  import org.apache.poi.hssf.usermodel.HSSFWorkbook;
  import org.apache.poi.ss.usermodel.Cell;
  import org.apache.poi.ss.usermodel.Row;
  
  public class TestMethodsDetails {
      public Map&lt;String, Integer&gt; getKnownGoodMap(String filePath) {
          String key = "";
          int value = 0;
          //filePath="TestMethodDetails.xls";
          Map&lt;String, Integer&gt; knownGoodMap = new LinkedHashMap&lt;String, Integer&gt;();
          try {
  
              FileInputStream file = new FileInputStream(new File(filePath));
  
              // Get the workbook instance for XLS file
              HSSFWorkbook workbook = new HSSFWorkbook(file);
  
              // Get first sheet from the workbook
              HSSFSheet sheet = workbook.getSheetAt(0);
  
              // Iterate through each rows from first sheet
              Iterator&lt;Row&gt; rowIterator = sheet.iterator();
              while (rowIterator.hasNext()) {
                  Row row = rowIterator.next();
  
                  // For each row, iterate through each columns
                  Iterator&lt;Cell&gt; cellIterator = row.cellIterator();
                  while (cellIterator.hasNext()) {
                      Cell cell = cellIterator.next();
  
                      switch (cell.getCellType()) {
                      case Cell.CELL_TYPE_NUMERIC:
                          value = (int) cell.getNumericCellValue();
                          break;
                      case Cell.CELL_TYPE_STRING:
                          key = cell.getStringCellValue();
                          break;
                      }
  
                      if (key != null &amp;&amp; value != Integer.MIN_VALUE) {
                          knownGoodMap.put(key, value);
                          key = null;
                          value = Integer.MIN_VALUE;
                      }
                  }
              }
              file.close();
          } catch (FileNotFoundException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }
          return knownGoodMap;
      }
      public static void main(String[] args) {
          TestMethodsDetails details = new TestMethodsDetails();
          System.out.println("Method Details : "+details.getKnownGoodMap("TestMethodDetails.xls"));
      }
  }
  </code></pre>
  
  <p>the above code prints the following : </p>
  
  <pre><code>Method Details : {Method Name=0, getLoggedinUserDetails=400, createRequisition=400, excelMDM=400, createOrder=400, confirmOrder=400}
  
  to be frank i really don't know what mechanism to use to store these details so that i enables easy access for me to process details, the user name and password will be different, i have given here some user and password for sample only 
  </code></pre>
  
  <p>Kindly help me to do this.</p>