title: export csv in zend framework
body: <p>I'm trying to export a database table as a .csv downloadable from the browser. My code is zend framework based and I'm almost there with the following action:</p>
  
  <pre><code>public function exportTableAction()
  {
      $this-&gt;_helper-&gt;layout-&gt;disableLayout();
      $this-&gt;_helper-&gt;viewRenderer-&gt;setNoRender();
  
      $fileName = $this-&gt;_getParam('fileName');
      $tableName = $this-&gt;_getParam('tableName');       
  
      header('Content-type: application/octet-stream');
      header('Content-Disposition: attachment; filename="'.$fileName.'"');
  
      echo $this-&gt;getCsv($tableName, $fileName);
  }
  </code></pre>
  
  <p>I can download my .csv file containing valid data. However, even if I disabled the layout and the renderer, I still get the output of the header, sidebar, and footer of my page at the end of my .csv file. Is there a way to disable any html output other than the one generated in my exportTableAction? Or can I send the header information and the csv string to the browser in a different way?</p>
  
  <p>BTW: I'm using the action stack plugin to help me render the header and sidebar as follows:</p>
  
  <pre><code>...
  $actionStack = $front-&gt;getPlugin('Zend_Controller_Plugin_ActionStack');
  $actionStack-&gt;pushStack($userlogAction);
  $actionStack-&gt;pushStack($rightcolAction);
  </code></pre>
  
  <p>Cheers, Adrian</p>