Note that there are some explanatory texts on larger screens.

plurals
  1. POPHPExcel output to browser doesn't work in IE
    text
    copied!<p>I have a PHP script that uses PHPExcel to open a template, insert values from a database query then return the result to the browser. It works perfectly in Firefox, but in Internet Explorer (8), when it attempts to open the file, it breaks with:</p> <blockquote> <p>Internet Explorer cannot download generate.php from my.domain.</p> <p>Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later.</p> </blockquote> <p>The code that I'm using (<code>generate.php</code>) is as follows:</p> <pre><code>// Open template $xlRead = PHPExcel_IOFactory::createReader('Excel5'); $xl = $xlRead-&gt;load('Template.xls'); $xl-&gt;setActiveSheetIndex(0); // Write data $xl-&gt;getActiveSheet()-&gt;fromArray($dbOutput, null, 'A1'); // Output to browser header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: post-check=0, pre-check=0', false); header('Pragma: no-cache'); header('Content-Type: application/vnd.ms-excel'); header('Content-Disposition: attachment;filename=MyReport.xls'); $xlWrite = PHPExcel_IOFactory::createWriter($xl, 'Excel5'); $xlWrite-&gt;save('php://output') </code></pre> <hr> <p><strong>EDIT</strong> Seems like this problem only affects IE when behind SSL. As such, this is an identical problem to several similar SO questions. People's advice is to tweak the headers, but so far, no combination of what I've seen as solutions has worked...</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload