abstract:把php中的excel顯示下載頁下載到本地硬盤需要設(shè)置頭信息:代碼:$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); header("Pragma: public"); header("Expires:
把php中的excel顯示下載頁下載到本地硬盤需要設(shè)置頭信息:
代碼:
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); header("Pragma: public"); header("Expires: 0"); header("Cache-Control:must-revalidate, post-check=0, pre-check=0"); //設(shè)置http協(xié)議,下載支持 header("Content-Type:application/force-download"); //設(shè)置下載的內(nèi)容是excel header("Content-Type:application/vnd.ms-execl"); //把下載的內(nèi)容設(shè)置為8機制流內(nèi)容 header("Content-Type:application/octet-stream"); //設(shè)置http協(xié)議,下載支持 header("Content-Type:application/download"); //下載excel名字的定義 header('Content-Disposition:attachment;filename="商品信息.xlsx"'); //內(nèi)容設(shè)置為二進制形式傳輸 header("Content-Transfer-Encoding:binary"); //把excel文件直接提供為下載形式 $objWriter->save('php://output');