title: Apache POI Streaming (SXSSF) for Reading
body: <p>I need to read large excel files and import their data to my application.</p>
  
  <p>Since POI takes up a large amount of heap to work, often throwing <code>OutOfMemory</code> errors, I found out that there is a <strong>Streaming</strong> API for handling excel data in a serial fashion (rather than loading the file completely into memory)</p>
  
  <p>I created a <code>xlsx</code> workbook, with a single worksheet, and typed in several values in cells and came up with the following code to attempt reading it:</p>
  
  <pre><code>public static void main(String[] args) throws Throwable {
      // keep 100 rows in memory, exceeding rows will be flushed to disk
      SXSSFWorkbook wb = new SXSSFWorkbook(new XSSFWorkbook(new FileInputStream("C:\\test\\tst.xlsx")));
      SXSSFSheet sheet = (SXSSFSheet) wb.getSheetAt(0);
      Row row = sheet.getRow(0);
      //row is always null
      while(row.iterator().hasNext()){ //-&gt; NullPointerException
          System.out.println(row.getCell(0).getStringCellValue());
      }
  }
  </code></pre>
  
  <p>However, despite being able to get its worksheets properly, it always comes with empty (<code>null</code>) rows.</p>
  
  <p>I have researched and found out several examples of the Streaming API in the internet, but none of them are about <strong>reading</strong> existing files, they're all about generating excel files.</p>
  
  <p>Is it actually possible to read data from existing <code>.xlsx</code> files in a stream?</p>