2015-11-01 141 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 ....你只能發送一個內容類型到瀏覽器以響應一個請求 –