title: How to read an excel file, sheet by sheet using jxl
body: <p>I'm working on a utility to convert excel file from one format to another. I was suggested to use jxl library to meet the requirements which are as follows.<br>read the file sheet by sheet and do following</p>
  
  <p>get the sheet name, make it key of a map and then get its column headers and make them value.</p>
  
  <p>it will result in following</p>
  
  <pre><code>   Map&lt;String, List&lt;String&gt;&gt; result = result&lt;key=sheetName, value=list of column headers&gt; 
  </code></pre>
  
  <p>Do this for all sheets in the given file</p>
  
  <p>I did this in following way</p>
  
  <p>public Map> function(String filePath ) throws IOException, BiffException{</p>
  
  <pre><code>       Map&lt;String, List&lt;String&gt;&gt; map = new HashMap&lt;String, List&lt;String&gt;&gt;(); 
      Workbook workBook=Workbook.getWorkbook(new File (filePath));
        String [] sheetNames = workBook.getSheetNames();
        Sheet sheet=null;
        List&lt;String &gt; fields = new ArrayList&lt;String&gt;();
        for (int sheetNumber =0; sheetNumber &lt; sheetNames.length; sheetNumber++){
           sheet=workBook.getSheet(sheetNames[sheetNumber]);
           for (int columns=0;columns &lt; sheet.getColumns();columns++){
               fields.add(sheet.getCell(columns, 0).getContents());
  
  
           }
           map.put(sheetNames[sheetNumber],fields);
  
        }
        return map;
  }
  </code></pre>
  
  <p>I did this with a hope of getting desired result but what it does is that it stores column headers of all sheets against each key as value. 
  i.e. if there are two sheets in file named as</p>
  
  <ol>
  <li>sheet1</li>
  <li>sheet2</li>
  </ol>
  
  <p>and following are their column headers</p>
  
  <p>Sheet1 -> id, name<br>
  sheet2 -> category, price</p>
  
  <p>then map will be like</p>
  
  <pre><code>result&lt;sheet1,&lt;id, name, caegory, price&gt;&gt;
  result&lt;sheet2,&lt;id, name, caegory, price&gt;&gt;
  </code></pre>
  
  <p>Can't figure out what I'm doing wrong?
  Help please, as my project has a lot of backend calculations and I don't want to spend a lot of time in this thing.</p>
  
  <p>Any help will be highly appreciated</p>