title: Either it writes the first Record or Last Record of the list, any suggestions to get it right
body: <p>I am having trouble writing data to an excel sheet. My other part of the program will generate an ArrayList of Objects and send it to this loop. This loop reads one object after the other and writes to the Excel sheet.</p>
  
  <p>I know I am missing something. It writes only the last object from the List.</p>
  
  <p>If I try placing this code inside the while loop:</p>
  
  <pre><code>FileOutputStream out = new FileOutputStream(writeExcel);
          writeExtraBook.write(out);
          out.close();
  </code></pre>
  
  <p>Then it writes only the first record to the file.</p>
  
  <p>Can anyone help me where I am doing wrong</p>
  
  <p>Here is the code that writes the data:  </p>
  
  <pre><code>String writeExcel = CONSTANTS.FOW_FILE_PATH;
  
      FileInputStream writeInput;
      try {
          writeInput = new FileInputStream(writeExcel);
  
          /** Create a POIFSFileSystem object **/
          POIFSFileSystem mywriteSystem = new POIFSFileSystem(writeInput);
          HSSFWorkbook writeExtraBook = new HSSFWorkbook(mywriteSystem);
          HSSFSheet myExtrasSheet = writeExtraBook.getSheet("FOW");
          HSSFRow extraRow = null;
          HSSFCell extraRowCell = null;
          int lastRowNumber = myExtrasSheet.getLastRowNum();
  
          Iterator&lt;FoWForm&gt; iter = fowList.iterator();
          while (iter.hasNext()) {
              extraRow = myExtrasSheet.createRow(lastRowNumber + 1);
              FoWForm form = iter.next();
              extraRowCell = extraRow.createCell(0);
              extraRowCell.setCellValue(lastRowNumber + 1);
              extraRowCell = extraRow.createCell(1);
              extraRowCell.setCellValue(form.getFowDesc());
              extraRowCell = extraRow.createCell(2);
              extraRowCell.setCellValue(form.getForCountry());
              extraRowCell = extraRow.createCell(3);
              extraRowCell.setCellValue(form.getMatchId());
              extraRowCell = extraRow.createCell(4);
              extraRowCell.setCellValue(form.getAgainstCountry());
  
          }
          FileOutputStream out = new FileOutputStream(writeExcel);
          writeExtraBook.write(out);
          out.close();
      } catch (FileNotFoundException e1) {
          // TODO Auto-generated catch block
          e1.printStackTrace();
      }
  </code></pre>