nagavinod494 / php-excel

Automatically exported from code.google.com/p/php-excel
MIT License
0 stars 0 forks source link

Internet Explorer 7 compatibility issue #4

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
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\"");

Original issue reported on code.google.com by wep...@gmail.com on 11 Jul 2007 at 12:14

GoogleCodeExporter commented 8 years ago
Much better. Thank you.

Original comment by ntsc.mic...@gmail.com on 7 May 2008 at 8:42

GoogleCodeExporter commented 8 years ago
Thanks 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.

Original comment by oliver.s...@gmail.com on 10 Sep 2009 at 4:00

GoogleCodeExporter commented 8 years ago
Outputting 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');

Original comment by stretch2...@hotmail.com on 6 Aug 2010 at 10:37