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

saving the pdf using phpexcel terminate the rest of the script

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

当您使用文件头将数据发送到 php://output 时,不要回显任何内容....回显将其数据发送到 php://output..... 您所做的只是在您要发送的文件的底部写入 [​​=12=]...并且它很可能也会损坏该文件