title: PHPExcel not downloading in mobile Safari
body: <p>I'm using <a href="http://phpexcel.codeplex.com/" rel="nofollow noreferrer">PHPExcel</a> to generate Excel files on the fly within my PHP application. I'm using the <code>Excel2007</code> format.</p>
  
  <p>When a user visits the URL that creates and forces the download of the Excel file, everything works great in all browsers <strong>except for mobile Safari</strong> (iPhone and iPad).</p>
  
  <p>Here are my headers and the <code>readfile</code> method:</p>
  
  <pre><code>header('Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  header('Content-disposition: attachment; filename=' . $file_name . '.xlsx;');
  header('Content-Length: ' . filesize($path_to_file . '.xlsx'));
  readfile($path_to_file . '.xlsx');
  </code></pre>
  
  <p>When I browse in mobile Safari to the URL that is supposed to download the .xlsx file I can actually see the tabs representing each worksheet of the file, but I don't see the actual data like so:</p>
  
  <p><img src="https://i.stack.imgur.com/QRL50.png" alt="no output for phpexcel on mobile safari"></p>
  
  <p>Furthermore, there are two additional weird behaviors I'm encountering with this:</p>
  
  <ul>
  <li>If I download this file on a desktop browser and email it to myself and open it with the Mail app in iOS, the file displays correctly.</li>
  <li>If I then take that attachment from the Mail app in iOS and import into, say, Dropbox, it does NOT display properly (it displays the same as the screenshot above).</li>
  <li>In Chrome, the file downloads properly and opens in Excel or even Numbers as expected, but in the console I see this message: <code>Resource interpreted as Document but transferred with MIME type application/vnd.ms-excel:</code></li>
  </ul>
  
  <p>Also, per the PHPExcel documentation, in place of <code>readfile</code> I have also tried:</p>
  
  <pre><code>$objWriter-&gt;save('php://output');
  </code></pre>
  
  <p>That, however, produces an error in mobile Safari that reads:</p>
  
  <pre><code>OfficeImportErrorDomain Error 912
  </code></pre>
  
  <p>To eliminate the <code>Content-type</code> as being the issue I've experimented by adjusting the <code>Content-type</code> to other values (such as <code>application/vnd.ms-excel</code> or even <code>application/download</code>). Unfortunately (though not surprisingly) those don't work either.</p>
  
  <p>Any guidance is greatly appreciate.</p>