doubiao9775 2015-11-01 16:26
浏览 60
已采纳

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

the echo statement is not running and the below script is also not running

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条回答 默认 最新

  • dongzhe6287 2015-11-01 17:15
    关注

    Don't echo anything when you're sending data to php://output with file headers.... echo sends its data to php://output..... all you're doing is writing "this is not diplaying" at the bottom of the file that you're sending.... and the likelihood is that it will also corrupt that file

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?