title: Forcing PHPExcel file to be saved and downloaded
body: <p>With one of my projects I have users 'export' information into Excel files using PHPExcel. When it works, it works perfectly.  Other times, only some people can actually open the files.</p>
  
  <p>Since I need to store the exports that are created, they are saved on the server and then the created file is downloaded using readfile(). When it doesn't work, (which is most of the time now) people get the 'wrong file format' error.  The really odd thing is that since the file is saved, they can try downloading that same file again.  Then it works.</p>
  
  <p>Here is my final save and download code:</p>
  
  <pre><code>header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  header('Content-Disposition: attachment;filename="'.$Temp_Export_File_Name.'"');
  header('Cache-Control: max-age=0');
  
  $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
  //$objWriter-&gt;save('php://output');
  $objWriter-&gt;save('../project_files_images/created_exports/'.$Temp_Export_File_Name);
  readfile('../project_files_images/created_exports/'.$Temp_Export_File_Name);
  exit;
  </code></pre>
  
  <p>Is there something wrong with this code that I am missing? The problem tends to show itself most for users of the latest versions of Office (Mac or Windows)</p>
  
  <p>Thanks for the input.</p>