争怎路由网:是一个主要分享无线路由器安装设置经验的网站,汇总WiFi常见问题的解决方法。

php备份excel表格的方法分享(代码)

时间:2024/4/10作者:未知来源:争怎路由网人气:

$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; width: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; }

$title参数的数据是一个一维数组,如下:
1405671-20180927144956692-1915647187.png

$data参数是一个二维数组,如下:

1405671-20180927144856465-401743902.png

调用方法:

$daochuData = DB::table('scholarship_to_weixin as s')->leftJoin('users as u','s.uid','=','u.id')
                ->leftJoin('admin as a','a.id','=','s.tx_checkid')
                ->orderBy('s.times','desc')
                ->select('s.*','u.nickname','u.tel','u.id as u_id','a.name as a_name','u.admin_beizhu_name')
                ->get();
            $title = array('序号','申请时间','申请人','备注名称','申请人手机号','提现金额','操作时间','操作人');
            $arr = [];
            foreach($daochuData as $k=>$v){
                $arr[] = array(
                        $k+1,
                        $v->times,
                        $v->nickname,
                        $v->admin_beizhu_name,
                        $v->tel,
                        $v->money,
                        $v->s_times,
                        $v->a_name
                );
            }
            
            $this->daochu_excel($arr,$title,'红包提现到微信记录');

结果:
1405671-20180927145650413-242680932.png希望对您有帮助。

以上就是php导出excel表格的方法分享(代码)的详细内容,更多请关注php中文网其它相关文章!


网站建设是一个广义的术语,涵盖了许多不同的技能和学科中所使用的生产和维护的网站。



关键词:php备份excel表格的办法分享(代码)




Copyright © 2012-2018 争怎路由网(http://www.zhengzen.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版