zoukankan      html  css  js  c++  java
  • PHP导出excel,无乱码

    php部分

    header("Content-type:application/octet-stream");
    header("Accept-Ranges:bytes");
    header("Content-type:application/vnd.ms-excel");
    header("Content-Disposition:attachment;filename=staff_list_".date('Ymd').".xlsx");
    header("Pragma: no-cache");
    header("Expires: 0");


    $OutputExcel = S('OutputExcel');
    $this->assign('OutputExcel',$OutputExcel)->display('test');

    html部分

    <html xmlns:o="urn:schemas-microsoft-com:office:office"
    xmlns:x="urn:schemas-microsoft-com:office:excel"
    xmlns="http://www.w3.org/TR/REC-html40">
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <head>
    <meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
    <style id="Classeur1_16681_Styles"></style>
    </head>
    <body>
    <div id="Classeur1_16681" align=center x:publishsource="Excel">
    <table x:str border=0 cellpadding=0 cellspacing=0 width=100% style="border-collapse: collapse">
    <tr>
    <th>序号</th>
    <th>姓名</th>
    <th>编号</th>
    <th>个人识别码</th>
    <th>身份证</th>
    </tr>
    <?php foreach ($OutputExcel as $key => $value): ?>
    <tr>
    <td>{$key+1}</td>
    <td>{$value['stuff_nicname']}</td>
    <td>{$value['stuff_number']}</td>
    <td>{$value['stuff_code']}</td>
    <td>{$value['stuff_idcard']}</td>
    </tr>
    <?php endforeach ?>
    </table>

  • 相关阅读:
    es5和es6的区别
    如何将word文档内容在网页显示方法
    实现在线浏览PDF文件的方法
    移动端开发兼容问题
    常见的浏览器兼容问题和解决方法
    弹层
    猜数字游戏
    米字格画布
    时钟制作
    关于屏幕高度
  • 原文地址:https://www.cnblogs.com/wenxinphp/p/5800312.html
Copyright © 2011-2022 走看看