output file format

Topics: Developer Forum, User Forum
Feb 22, 2012 at 7:31 AM

    header('Content-Type: application/vnd.ms-excel');
    header('Content-Disposition: attachment;filename="stats.xls"');
    header('Cache-Control: max-age=0');

    $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');

this is the code to send excel table to user. but it outputs file in wrong format

i don't know how to post images here...

here you can see a screen from excel editor

help me please

Feb 22, 2012 at 8:50 AM

Save the file to disk, then open it in a text editor and look for any error messages or white space at the beginning or end of the file. White space is the most likely cause of this.

Feb 22, 2012 at 9:24 AM
Edited Feb 22, 2012 at 9:24 AM

i found a solution. there were 3 symbols at the begining. i had to just clean output buffer.

thanks for your reply

Feb 22, 2012 at 5:45 PM

The 3 symbols at the beginning are almost certainly a BOM marker from one of your script files. Most editors/IDEs allow an option to save as UTF-8 without BOM

Mar 13, 2013 at 10:16 AM
Hi I am new to developing,
I have the same problem with you Sir Stassus, i tried using output buffer but i can't understand the documentation of ob_start() or ob_end() or any ob out there. may you please specify where did you put the cleaning of output buffer?
Thanks in advance.