首页 > Web开发 > 详细

PHP提供excel下载接口

时间:2019-06-28 18:58:07      阅读:101      评论:0      收藏:0      [点我收藏+]

header信息填好就行,直接echo会在浏览器输出乱码

<?php

set_time_limit(0);
ini_set(memory_limit, -1);

try{
    // 上传时间
    $filePath = worl.xlsx;
    header(Content-Description: attachment; File Transfer);  
    header(Content-Disposition: attachment; filename=test.xlsx);  
    header(Content-Transfer-Encoding: binary);  
    header(Cache-Control: must-revalidate, post-check=0, pre-check=0);  
    header(Expires: 0);  

    // 如果文件非常大的情况可以使用ob缓冲区 - 先加载到缓冲区再输出
    echo file_get_contents($filePath);

} catch (\Exception $e) {
   echo 0;
}

 

PHP提供excel下载接口

原文:https://www.cnblogs.com/xuweiqiang/p/11104054.html

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