I came across a major compatibility issue with Internet Explorer 7 and Microsoft Office 2007/3.
Headers sent cause IE to try to open the file inline but for the 90% of tests the content was corrupted or IE was unable to handle the file. I fixed the problem changing content disposition header to attachment
header("Content-Disposition: attachment; filename=\"" . $filename . ".xls\"");
and with 2 additional headers that force the browser to not cache the request. Here's the final piece of code
// deliver header (as recommended in php manual)
header("Content-Type: application/vnd.ms-excel; charset=UTF-8");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Disposition: attachment; filename=\"" . $filename .
".xls\"");
Comment #1
Posted on May 7, 2008 by Swift BearMuch better. Thank you.
Comment #2
Posted on Sep 10, 2009 by Swift HorseThanks for this input/fix. I will try to improve the sent header in one of the next version. It's quite difficult to test this in all MS/Office/IE combinations.
Comment #3
Posted on Aug 6, 2010 by Happy WombatOutputting to IE over SSL/HTTPS also causes and issue due to it not being able to interpret the header correctly.
I added the following additional header to your code :-
header('Pragma: public');
Status: Accepted
Labels:
Type-Defect
Priority-Medium