首页 > 其他 > 详细

把生成的excel文件直接提供为下载页效果

时间:2016-11-17 20:14:26      阅读:232      评论:0      收藏:0      [点我收藏+]

把php中的excel显示下载页下载到本地硬盘需要设置头信息:

技术分享

代码:

$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, ‘Excel2007‘);
header("Pragma: public");
header("Expires: 0");
header("Cache-Control:must-revalidate, post-check=0, pre-check=0");
//设置http协议,下载支持
header("Content-Type:application/force-download");
//设置下载的内容是excel
header("Content-Type:application/vnd.ms-execl");
//把下载的内容设置为8机制流内容
header("Content-Type:application/octet-stream");
//设置http协议,下载支持
header("Content-Type:application/download");
//下载excel名字的定义
header(‘Content-Disposition:attachment;filename="商品信息.xlsx"‘);
//内容设置为二进制形式传输
header("Content-Transfer-Encoding:binary");
//把excel文件直接提供为下载形式
$objWriter->save(‘php://output‘);

 

把生成的excel文件直接提供为下载页效果

原文:http://www.cnblogs.com/yangzailu/p/6074507.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!