php导出excel表

  <?php
    include(‘mysql.php‘);
    $act_key = $_GET[‘act_key‘];
    $act_id = $_GET[‘act_id‘];

    $where = ‘act_id="‘.$act_id.‘"‘;
    $re = select(‘fpt_contact‘,$where);
    while($row=mysql_fetch_assoc($re)){
        $where = ‘member_id="‘.$row[‘member_id‘].‘"‘;
        $row[‘m‘] = mysql_fetch_assoc(select(‘fpt_member‘,$where));
        $row[‘zwh‘] = $row[‘member_seatnum‘];
        $row[‘time‘] = $row[‘contact_date‘];
        $me[] = $row;
    }
        foreach ($me as $v) {
            $row[‘act_key‘] = $act_key;
            $uns = unserialize($v[‘m‘][‘member_values‘]);
            $row[‘name‘] = $uns[‘name‘];
            $row[‘gender‘] = $uns[‘gender‘];
            $row[‘wechatno‘] = $uns[‘wechatno‘];
            $row[‘member_headimgurl‘] = $v[‘m‘][‘member_headimgurl‘];
            $row[‘email‘] = $uns[‘email‘];
            $row[‘phone‘] = $uns[‘phone‘];
            $row[‘status‘] = $uns[‘status‘];
            $row[‘time‘] = $uns[‘time‘];
            $row[‘fund‘] = $uns[‘fund‘];
            $row[‘fangxiang‘] = $uns[‘fangxiang‘];
            $row[‘business‘] = $uns[‘business‘];
            $row[‘experience‘] = $uns[‘experience‘];
            $row[‘jingyan‘] = $uns[‘jingyan‘];
            $row[‘woshi‘] = $uns[‘woshi‘];
            $row[‘xunzhao‘] = $uns[‘xunzhao‘];
            $row[‘tigong‘] = $uns[‘tigong‘];
            $row[‘dedao‘] = $uns[‘dedao‘];
            $row[‘aboutme‘] = $uns[‘aboutme‘];
            $row[‘age‘] = $uns[‘age‘];
            $row[‘xingzuo‘] = $uns[‘xingzuo‘];
            $row[‘date‘] = $v[‘contact_date‘];
            $row[‘bm‘] = $v[‘m‘][‘member_bm‘];
            $row[‘qd‘] = $v[‘m‘][‘member_qd‘];
            $row[‘zwh‘] = $v[‘member_seatnum‘];
            $date[] = $row;
        }
 //var_dump($date);die();
    $title = array(‘活动关键字‘,‘姓名‘,‘性别‘,‘微信号‘,‘头像‘,‘邮箱‘,‘手机号‘,‘目前状态‘,‘时间投入‘,‘资金投入‘,‘创业方向‘,‘本人行业‘,
            ‘行业经验‘, ‘创业经验‘, ‘本人标签‘, ‘择友标签‘, ‘我能提供‘, ‘我想到到‘, ‘自我简介‘, ‘年龄段‘, ‘星座‘, ‘报名时间‘,
            ‘报名次数‘, ‘签到次数‘, ‘座位号‘);
//var_dump($title);die();
    exportexcel($date,$title,$act_key);
    function exportexcel($data=array(),$title=array(),$filename=‘‘){
        header("Content-type:application/octet-stream");
        header("Accept-Ranges:bytes");
        header("Content-type:application/vnd.ms-excel");
        header("Content-Disposition:attachment;filename=".$filename.".xls");
        header("Pragma: no-cache");
        header("Expires: 0");
    //导出xls 开始
    if (!empty($title)){
        foreach ($title as $k => $v) {
            $title[$k]=iconv("UTF-8", "GB2312",$v);
        }
        $title= implode("\t", $title);
        echo "$title\n";
    }
    if (!empty($data)){
        foreach($data as $key=>$val){
            foreach ($val as $ck => $cv) {
                $data[$key][$ck]=iconv("UTF-8", "GB2312", $cv);
            }
            $data[$key]=implode("\t", $data[$key]);

        }
        echo implode("\n",$data);
    }

 }





郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。