title: PHPExcel - Write/append in chunks
body: <p>I am using the PHPExcel framework to try to write out a very large excel document from a mysql query. </p>
  
  <p>Everything works fine until I hit the 5000 row mark (or there about's) where the page gets flagged with the error:</p>
  
  <pre><code>Fatal error: Allowed memory size of xxx bytes exhausted (tried to allocate yyy bytes) in zzz on line aaa
  </code></pre>
  
  <p>I know this is documented, and I have adjusted the memory allocation on the server but even so I am still hitting the ceiling. I have also tried to turn off formatting, but in reality I will need it on. </p>
  
  <p>So is there a way to write in small chunks, or append to the excel document so I don't exhaust the memory allocation? I am thinking along the lines of the page writing say 1000 lines, then redirect to itself and process the next 1000 using a GET to keep track. For example: </p>
  
  <p><code>index.php?p=0</code> </p>
  
  <p>then redirect to </p>
  
  <p><code>index.php?p=1000</code>, </p>
  
  <p>But I can't find a way to append to an existing document without opening up the whole thing. </p>