probleme output

Topics: Developer Forum
Dec 22, 2010 at 2:06 PM
Edited Dec 22, 2010 at 2:10 PM

when i use

header('Content-Type: application/');
    header('Content-Disposition: attachment;filename="myfile.xls"');
    header('Cache-Control: max-age=0');
    $writer = PHPExcel_IOFactory::createWriter($workbook, 'Excel5');

the file is corrupted whith stranges symbols.
I have folowed all recomandations of the documentation about output PHP.

  • Make sure not to include any echo statements or output any other contents than the Excel file. There should be no whitespace before the opening <?php tag and at most one line break after the closing ?> tag (which can also be omitted to avoid problems).

Make sure that your script is saved without a BOM (Byte-order mark). (Because this counts as echoing output)


And have install the lastest version in prod 1.7.5

But no way, it doesn't work. And it's the same thing with a xlsx 2007.

thanks for help.


Dec 22, 2010 at 3:36 PM

Without seeing the actual file output, it's difficult to say whether it is corrupted in any way. An Excel xls file is a binary document, which means that it's full of "strange symbols"... open any normal xls file to see what I mean. Likewise, an Excel xlsx file is zip compressed, so again it contains what appear to be "strange symbols". For an xlsx file, you can try unzipping it to see the actual content. However, as I said, without seeing the actual generated file, it's impossible to say if the "strange symbols" are valid, or are a corruption.

Dec 27, 2010 at 8:22 AM

Hi Mark, 

Thanks a lot for your help.

I think the file was realy corrupted because there was a message at the opening saying that it was corrupted: in Excel5 => Message => possible to open file but there was some hieroglyphes inside. in Execel 2007 => message => and impossible to open. 

But i have found the solution : it was the : requireonce() function (including the conection login script) who made this problem. And i 've try whith include(), includeonce(), require() and it's the same thing.

So i simply put the 4 lines naking connection directly in my phpexcel script  and every thing is right.

If you have any questions, or if you want a sample of the generated file ...

Sorry about my bad english,



Dec 29, 2010 at 11:57 AM

It's probable then that the file you were requiring was echoing some output, or that it contained white space (such as a new line) outside of the php tags