phpexcel导出 怎么实现点击导出后 弹出打开保存对话框 选择保存路径 保存
在使用phpexcel导出时 发现一调用就直接生成一个excel的文件了,不能保存到本地,怎么实现点击导出后,弹出保存对话框并选择保存路径来保存呢,求实例或者思路! PhpExcel 导出 php
[解决办法]
生成是在服务器生成的吧 用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/)原创,如转载请注明来源
能解吗
[解决办法]