title: PHPExcel can't save the file or download it
body: <p>I'm trying to code a function in PHP to export some data to Excel file.
  The problem is if I save it to the server it does work, but if I try to send to the browser using php://output it just doesn't work. It doesn't even show the download window. I' ve been getting these as response:</p>
  
  <blockquote>
    <p>PK����a�B%���a��������[Content_Types].xml͔]K�0���%��f�
    "�v��R���kX����׿�m��+����4�&lt;�'��2�jgs6�,+��v����Sz���<em>a�����tr5^�=Bb�9+c����,��9��.T"�kXr/�J,���[.��`ck6�?h�\��,</em>���ܠ}3�c�C+��9�-E��|c�j�BKPN�+�d��u��O1�
    o��Ba +���G�</p>
  </blockquote>
  
  <p><strong>The headers are:</strong> </p>
  
  <pre><code>Response Headers
  Cache-Control   no-store, no-cache, must-revalidate, post-check=0, pre-check=0
  Connection  Keep-Alive
  Content-Disposition attachment;filename="Report.xlsx"
  Content-Type    application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
  Date    Wed, 29 May 2013 10:08:10 GMT
  Expires Thu, 19 Nov 1981 08:52:00 GMT
  Keep-Alive  timeout=15, max=78
  Last-Modified   Wed, 29 May 2013 10:08:11 GMT
  Pragma  no-cache
  Server  Apache/2.2.14 (Ubuntu)
  Transfer-Encoding   chunked
  X-Powered-By    PHP/5.3.2-1ubuntu4.19
  Request Headers
  Accept  */*
  Accept-Encoding gzip, deflate
  Accept-Language en-US,en;q=0.5
  Cookie  PHPSESSID=075r4aaqrvcnbca5sshjvm0jq7; 87293ba76812d31889be0901b086dd73=5h4jriq5c7r9vdt3m2u2u9up43; d82d00149fafbe651c9ba75a9804bbc9=en-GB
  Host    150.145.139.3:8889
  Referer 
  User-Agent  Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:20.0) Gecko/20100101 Firefox/20.0
  X-Requested-With    XMLHttpRequest
  </code></pre>
  
  <p><strong>Here's my code:</strong></p>
  
  <pre><code>&lt;?php
  error_reporting(E_ALL);
  ini_set('display_errors', TRUE);
  ini_set('display_startup_errors', TRUE);
  
  
  
  date_default_timezone_set('Europe/Rome');
  
  require_once 'Classes/PHPExcel.php'; 
  /** PHPExcel_IOFactory */
  include 'Classes/PHPExcel/IOFactory.php';
  
  
  
  $target ='templates/';
  $fileType = 'Excel2007';   
  $InputFileName = $target.'richiesta.xlsx';   
  $OutputFileName = $target     .'Richiesta_'.$_SESSION['User'].'_'.$_SESSION['Last'].'_'.$dat.'.xlsx';
  
  
  
  //Read the file (including chart template) 
  $objReader = PHPExcel_IOFactory::createReader($fileType); 
  //$objReader-&gt;setIncludeCharts(TRUE);
  $objPHPExcel = $objReader-&gt;load($InputFileName); 
  
   //Change the file 
  
  
  $objPHPExcel-&gt;setActiveSheetIndex(0)
  // Add data
              -&gt;setCellValue('C3','10' )
              -&gt;setCellValue('C4','20' )
              -&gt;setCellValue('C5','30')
              -&gt;setCellValue('C5','40' );
  
  
  $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $fileType);
  
  //$objWriter-&gt;save($OutputFileName);  //This one WORKS FINE!!!
  
  
  
  
  header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
  header("Cache-Control: no-store, no-cache, must-revalidate");
  header("Cache-Control: post-check=0, pre-check=0", false);
  header("Pragma: no-cache");
  header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  header('Content-Disposition: attachment;filename="Report.xlsx"');
  
  
  $objWriter-&gt;save('php://output'); //NOT WORKING :-(
  $objPHPExcel-&gt;disconnectWorksheets();
  unset($objPHPExcel);
  
  exit;
  </code></pre>
  
  <p>I'm getting depressed about this problem once I have to finish the project this week.
  I really appreciate any kind of help!</p>