PHPExcel_Writer_Excel5 cant save file at client

Dec 25, 2007 at 8:08 PM
//here's my codes:
$objWriter = new PHPExcelWriterExcel5($objPHPExcel);
header("Pragma: public");
header("Expires: 0");
header("Cache-Control:must-revalidate, post-check=0, pre-check=0");
header("Content-Type:application/force-download");
header("Content-Type:application/vnd.ms-execl");
header("Content-Type:application/octet-stream");
header("Content-Type:application/download");;
header('Content-Disposition:attachment;filename="test.xls"');
header("Content-Transfer-Encoding:binary");
$objWriter->save('php://output');

when a client browser saved the file, and find there's all error codes in it!
But when use "$objWriter->save('test.xls');" instead,create a file on server,it's correct!
Does anybody who know what wrong with it?
Help!!!Thanks !!!
Coordinator
Dec 26, 2007 at 9:48 AM
Are there any empty lines or other non-excel data sent to the client? Can you try generating it on the server, and then using fpassthru() to send it to the client?
Dec 26, 2007 at 10:40 AM
Thank maartenba!
I find that when I require_once a php file before main codes,the generated excel file will be wrong!
for example:
//conn.php
$host='localhost';
$user='root';
$pass='111';
mysql_connect codes here....
//main.php
require_once 'conn.php';
excel_writer codes here........



maartenba wrote:
Are there any empty lines or other non-excel data sent to the client? Can you try generating it on the server, and then using fpassthru() to send it to the client?