title: PHPExcel return a corrupted binary file
body: <p>I want to write a reference xls file and retrieve the result.
  When I tested with a single file, it works but when the reference file is complex, this returns me a corrupt file with with kinds of data:
  <img src="https://i.stack.imgur.com/oT6P1.png" alt="enter image description here"></p>
  
  <p><img src="https://i.stack.imgur.com/sj38F.png" alt="enter image description here">
  Which is at the beginning like this:
  <img src="https://i.stack.imgur.com/ZiTAg.png" alt="enter image description here"></p>
  
  <p>My php file is:</p>
  
  <pre><code>error_reporting(E_ALL);
  ini_set('display_errors', TRUE);
  ini_set('display_startup_errors', TRUE);
  date_default_timezone_set('Europe/London');
  
  if (PHP_SAPI == 'cli')
      die('This example should only be run from a Web Browser');
  
  /** Include PHPExcel */
  require_once '../phpexcel/Classes/PHPExcel.php';
  $objPHPexcel = PHPExcel_IOFactory::load('../upload/ref/fileref.xls');
  
  $objWorksheet = $objPHPexcel-&gt;getActiveSheet();
  
  $objWorksheet = $objPHPexcel-&gt;getActiveSheet();
  $objWorksheet-&gt;getCell('B1')-&gt;setValue('toto');
  $objWorksheet-&gt;getCell('B3')-&gt;setValue('toto');
  
  
  
  
  
  
  
  header('Content-Type: application/vnd.ms-excel');
  header('Content-Disposition: attachment;filename="newfiletodownload.xls"');;
  header('Cache-Control: max-age=0');
  header('Cache-Control: max-age=1');
  header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
  header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
  header ('Cache-Control: cache, must-revalidate');
  header ('Pragma: public');
  
  $objWriter = PHPExcel_IOFactory::createWriter($objPHPexcel, 'Excel5');
  $objWriter-&gt;save('php://output');
  </code></pre>
  
  <p>Do you have solution ?
  Thanks, Neyoh</p>