使用phpexcel保存pdf会终止脚本的其余部分

时间:2015-11-01 16:26:01

标签: php phpexcel dompdf

echo语句未运行且以下脚本也未运行

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

1 个答案:

答案 0 :(得分:0)

当您使用文件标题向php://output发送数据时,不要回复任何内容.... echo将其数据发送到php://output .....所有你&#39 ;我正在写"this is not diplaying"在您发送的文件的底部....并且可能是它也会破坏该文件