title: Writing 1 million records to Excel file with 300 columns
body: <p>I am using Apache POI Streaming API- SXSSFWorkbook to write data to excel file.
  But Excel file is getting corrupted for more than 100 000 records with 300 columns generally if the size is greater then 100Mb. Is there any way for writing huge data to excel file. </p>
  
  <pre><code>class Test1 {
     public static void main(String[] args) throws FileNotFoundException,  {
  
  
      SXSSFWorkbook workbook = new SXSSFWorkbook(100);
  
      workbook.setCompressTempFiles(true);
      Sheet sheet = null;
      Row row = null;
      Cell cell = null;
      sheet =  workbook.createSheet("Demo1");
      FileOutputStream outStream = new FileOutputStream("D:\\Test1.xlsx");
      try {
  
          for (int i = 0; i &lt; 100000; i++) {
              row = sheet.createRow(i);
              for (int j = 0; j &lt; 300; j++) {
                  cell = row.createCell(j);
                  cell.setCellValue(" row : "+i +" col: "+ j);
              }
          }
  
  
          workbook.write(outStream);
  
      } catch (Exception exception) {
          exception.printStackTrace();
      } finally {
          workbook.dispose();
          try {
              outStream.close();
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
  
      }
  }
  </code></pre>
  
  <p>Edit 1:</p>
  
  <p>What I found is, it is not the problem with Apache POI Streaming Api.It is generating the file with 1 Million records. But Excel is not loading that file. It is giving 'There isn't enough memory to complete this action' error.</p>
  
  <p>I am using Excel 2013 32 bit version which can use only up till 2GB of memory. The excel file I created with 100k records and 300 columns has file size 108MB. When I try to open this file in Excel it is taking up whole lot of System memory. As soon as the memory consumption reaches 1.7 MB Excel is giving an error.</p>
  
  <p>What is the minimum configuration to load 1million rows generated using Apache Streaming API? Any help would be appreciated.</p>
  
  <p>Thanks.</p>
  
  <p>Edit 2:
  If I open Excel file generated using Apache Streaming Api in zip format(by renaming .xlsx to .zip),size of the xml file in xl->worksheets folder is around 2GB for 100k records and 300 columns. Is there any way to reduce the size of this xml file.</p>