时间:2021-07-01 10:21:17 帮助过:12人阅读
生成是在服务器生成的吧 用js指向生成的excel文件 浏览器无法打开就会提示下载了吧?
纯猜测没试过.
最后保存阶段 的->save()
改为:
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header('Content-Disposition:inline;filename="'.$FileName.'"');
header("Content-Transfer-Encoding: binary");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Pragma: no-cache");
$objWriter->save('php://output');
// sheet名称
$objPHPExcel->getActiveSheet()->setTitle('绩效考核统计');
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
$objPHPExcel->setActiveSheetIndex(0);
// Redirect output to a clients web browser (Excel5)通知下载
$fn="gxtj-$year-$jd.xls";
header('Content-Type: application/vnd.ms-excel; charset=utf-8');
header("Content-Disposition: attachment;filename=$fn");
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
exit;
声明:本文为刘兴(http://deepfuture.iteye.com/)原创,如转载请注明来源
能解吗
最后保存阶段 的->save()
改为:
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header('Content-Disposition:inline;filename="'.$FileName.'"');
header("Content-Transfer-Encoding: binary");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Pragma: no-cache");
$objWriter->save('php://output');
请问能具体点吗,我用的是zendframework 是在后台的Action中从数据库取数据放到excl文档中的,这些代码放上去,没有反应
最后保存阶段 的->save()
改为:
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header('Content-Disposition:inline;filename="'.$FileName.'"');
header("Content-Transfer-Encoding: binary");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Pragma: no-cache");
$objWriter->save('php://output');
请问能具体点吗,我用的是zendframework 是在后台的Action中从数据库取数据放到excl文档中的,这些代码放上去,没有反应
不是放上去。。变量名你不需要改吗?你的实例化PHPEXCEL类是$objWriter么?改为你自己的。
ps:打开错误提示,看看错误是什么,没有反应可能是有错误的
http://www.cnblogs.com/dahuzizyd/archive/2012/07/06/2579738.html