2015-11-01 86 views
1

回声语句的其余部分保存PDF没有运行,并且下面的脚本也没有运行使用phpexcel终止脚本

header("HTTP/1.1 200 OK"); 
       header("Pragma: public"); 
       header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
       header("Cache-Control: private", false); 
       header('Content-Type: application/pdf'); 
       header('Content-Disposition: attachment;filename="rename.pdf"'); //tell browser what's the file name 
       header('Cache-Control: max-age=0'); //no cache 
       $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'PDF'); 
       $objWriter->setSheetIndex($i); 

       $objWriter->save('php://output'); 
       echo "this is not diplaying"; //code get terminated 

回答

0

当你与文件数据发送到php://output不回应任何事情头文件....回声发送它的数据到php://output .....你正在做的是写"this is not diplaying"在你发送的文件的底部....可能是它也会损坏该文件

+0

谢谢...先生任何替代我的问题。 – kashif

+0

是的.....当你输出一个文件到浏览器时,不会回应其他任何东西.....这不是PHPExcel特有的,它适用于任何生成或写入php://输出的文件通过PHP ....你只能发送一个内容类型到浏览器以响应一个请求 –