zoukankan      html  css  js  c++  java
  • 自定义导出表格

    可参考: https://www.cnblogs.com/koxi/p/9703184.html

    $filename = 'demo';
    $title = array('序号','申请时间','申请人','备注名称','申请人手机号','提现金额','操作时间','操作人');
    $data = array(array());
    ob_end_clean();
    Header('content-Type:application/vnd.ms-excel;charset=utf-8');

    header("Content-Disposition:attachment;filename=".$filename.".xls");
    //处理中文文件名
    $ua = $_SERVER["HTTP_USER_AGENT"];

    $encoded_filename = urlencode($filename);
    $encoded_filename = str_replace("+", "%20", $encoded_filename);
    if (preg_match("/MSIE/", $ua) || preg_match("/LCTE/", $ua) || $ua == 'Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko') {
    header('Content-Disposition: attachment; filename="' . $encoded_filename . '.xls"');
    }else {
    header('Content-Disposition: attachment; filename="' . $filename . '.xls"');
    }
    header ( "Content-type:application/vnd.ms-excel" );


    $html = "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
    <html xmlns='http://www.w3.org/1999/xhtml'>
    <meta http-equiv='Content-type' content='text/html;charset=UTF-8' />
    <head>

    <title>".$filename."</title>
    <style>
    td{
    text-align:center;
    font-size:12px;
    font-family:Arial, Helvetica, sans-serif;
    border:#1C7A80 1px solid;
    color:#152122;
    auto;
    }
    table,tr{
    border-style:none;
    }
    .title{
    background:#7DDCF0;
    color:#FFFFFF;
    font-weight:bold;
    }
    </style>
    </head>
    <body>
    <table width='100%' border='1'>
    <tr>";
    foreach($title as $k=>$v){
    $html .= " <td class='title' style='text-align:center;'>".$v."</td>";
    }

    $html .= "</tr>";

    foreach ($data as $key => $value) {
    $html .= "<tr>";
    foreach($value as $aa){
    $html .= "<td>".$aa."</td>";
    }

    $html .= "</tr>";

    }
    $html .= "</table></body></html>";
    echo $html;
    exit;

  • 相关阅读:
    Vue3 模板语法
    Vue 起步
    [原创]CPA、CPC、CPM、CVR、CTR和ROI分别代表什么?
    Redis 线程模型
    BIO和NIO区别以及原理
    kafka简介&kafka安装
    python测试开发django-109.ModelForm模型表单的使用
    HttpRunner2.X 版本和 3.X 版本的区别到底有哪些?(吐血总结!)
    python测试开发django-108.form组件Select下拉框读取数据库内容
    DDD领域驱动设计架构模式:防腐层(Anti-corruption layer)
  • 原文地址:https://www.cnblogs.com/JdsyJ/p/9719314.html
Copyright © 2011-2022 走看看