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>

  • 相关阅读:
    Eclipse中properties文件中文显示编码、乱码问题
    Eclipse中安装yml插件( YEdit )
    Java中如何返回Json数组
    ASIFormDataRequest 登录
    Safari里使用JsonView
    beginUpdates和endUpdates
    svn log 不显示日志的问题
    svn代码回滚命令
    Tomcat: localhost:8080 提示404
    android定时三种方式
  • 原文地址:https://www.cnblogs.com/wenxinphp/p/5800312.html
Copyright © 2011-2022 走看看