title: How to append to existing excel file using Java HSSF
body: <p>I am still relatively new to Java and have cobbled together enough code that allows me to write my data out to a new excel file.  However, I want it to write (append to the end) to the existing file.  prepareDataToWriteToExcel() gets some data to write 3 columns of data.</p>
  
  <pre><code>public List writeDataToExcelFile(String fileName) throws IOException {
      Map excelData = prepareDataToWriteToExcel();
      List receiversList=new  ArrayList();
      HSSFWorkbook myWorkBook = new HSSFWorkbook();
      HSSFSheet mySheet = myWorkBook.createSheet();
      HSSFRow myRow = null;
      HSSFCell myCell = null;
      Iterator it=excelData.entrySet().iterator(); 
      int rowNum=0;
      while (it.hasNext()) {
          myRow = mySheet.createRow(rowNum);
          Map.Entry pairs = (Map.Entry)it.next();
          String[]arr= (String[]) pairs.getValue();
          for (int cellNum = 0; cellNum &lt; arr.length ; cellNum++){
              myCell = myRow.createCell((short) cellNum);
              myCell.setCellValue(arr[cellNum]);     
          }
          receiversList.add(arr[2]);
          rowNum++;
      }
      try{
          FileOutputStream out = new FileOutputStream(fileName);
          myWorkBook.write(out);
          System.out.println("WRITING TO EXCEL COMPLETED");
          out.close();
      }catch(Exception e){}  
      return receiversList;
  }
  </code></pre>