title: Creating multiple sheets using Apache poi and servlets
body: <p>When i am creating multiple sheets using Apache poi and servlets. It is creating the sheet but not writing the data to file. I am trying to write the first 1000 records to sheet1 and next 1000 to sheet2 through below code, but not working</p>
  
  <pre><code>private void writeDataToExcelFile(String string,
          ArrayList&lt;ArrayList&lt;String&gt;&gt; excelData, OutputStream outputStream) {
      HSSFWorkbook myWorkBook = new HSSFWorkbook();
      String sheetName = "";
      sheetName = "Document-" + 0;
      HSSFSheet mySheet = myWorkBook.createSheet();
      HSSFRow myRow = null;
      HSSFCell myCell = null;
      for (int rowNum = 0; rowNum &lt; excelData.size(); rowNum++) {
          ArrayList&lt;String&gt; rowData = excelData.get(rowNum);
          if(rowNum&gt;0 &amp;&amp; rowNum%1000 == 0)
          {
              sheetName = "Document-" + (rowNum/1000);
              mySheet = myWorkBook.createSheet();
          }
          myRow = mySheet.createRow(rowNum);
          for (int cellNum = 0; cellNum &lt; rowData.size(); cellNum++) {
              myCell = myRow.createCell(cellNum);
              myCell.setCellValue(rowData.get(cellNum));
          }
      }
      System.out.println("Last row:" + mySheet.getLastRowNum());
      System.out.println("Row number:" + mySheet.rowIterator().next().getRowNum());
      try {
          myWorkBook.write(outputStream);
      } catch (Exception e) {
          e.printStackTrace();
      } finally {
          try {
              outputStream.close();
          } catch (IOException e) {
              e.printStackTrace();
          }
      }
  }
  </code></pre>
  
  <p>What is wrong with my logic.Please do the needful help.
  Thanks</p>