php下载指定路径的excel代码:
$download_path = ROOT_PATH.’admin/download/’;
$filename2 = “库存明细(含有效期).xls”;
$filename = “test.xls”;
$file =fopen($download_path.$filename,”r”);
Header(“Content-type:application/octet-stream”);
Header(“Accept-Ranges:bytes”);
header(“Content-Type:application/msexcel”);
Header(“Accept-Length:”.filesize($download_path.$filename));
Header(“Content-Disposition:attachment;filename=”.$filename2);
echo
fread($file,filesize($download_path.$filename));
fclose($file);
exit ();
注意:中文名的excel名称会报错,这里用英文的替换,最后导出来的时候再设置回中文就行了
小杰博客 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:php下载excel文件