• 技术文章 >php教程 >php手册

    php导入到Excel 的 utf8、gbk 编码

    2016-06-13 10:33:54原创361
    php导入到excel-支持utf8和gbk两种编码

    php导入到excel乱码是因为utf8编码在xp系统不支持所有utf8编码转码一下就完美解决了

    utf-8编码案例

    header("Content-Type: application/vnd.ms-excel; charset=UTF-8");
    header("Pragma: public");
    header("Expires: 0");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Content-Type: application/force-download");
    header("Content-Type: application/octet-stream");
    header("Content-Type: application/download");
    header("Content-Disposition: attachment;filename=11.xls ");
    header("Content-Transfer-Encoding: binary ");
    ?>
    $filename="php导入到excel-utf-8编码";
    $filename=iconv("utf-8", "gb2312", $filename);
    echo $filename;
    ?>

    gbk编码案例

    header("Content-Type: application/vnd.ms-excel; charset=UTF-8");
    header("Pragma: public");
    header("Expires: 0");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Content-Type: application/force-download");
    header("Content-Type: application/octet-stream");
    header("Content-Type: application/download");
    header("Content-Disposition: attachment;filename=11.xls ");
    header("Content-Transfer-Encoding: binary ");
    ?>
    $filename="php导入到excel-utf-8编码";
    echo $filename;
    ?>

    访问网站的时候就下载到excel里面

    要弄单元格区别的话

    用table表格做网页的就可以了

    声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
    上一篇:分享PHP技术开发技巧 下一篇:php强制下载文件
    千万级数据并发解决方案

    相关文章推荐

    • gd库图片下载类实现下载网页所有图片的php代码• PHP将DateTime对象转化为友好时间显示的实现代码• PHP+XML 制作简单的留言本 图文教程• php下几个常用的去空、分组、调试数组函数• 轻松修复Discuz!数据库
    1/1

    PHP中文网