PHP实现导出表格,简单,方便

'正常 未兑换',2=>'正常 已兑换',3=>'正常 过期',4=>'正常商家已提现',5=>'作废'];
            // 查询满足要求的总记录数
 			$count = 10;
     
            $ppp = ceil($count/10000);
            $pp = range(1,$ppp);
            foreach ($pp as $kkk => $vvv) {
                //可以自己查数据库
                $rs[$kkk] = array(
                	array(
                		'nickname' => '张三',
	                	'coder'	=> '12',
	                	'manager' => '管理员1',
	                	'phone'	=> '123456',
	                	'exchange_time' => '2019-04-19',
	                	'winning_time' => '2019-04-22',
	                	'title'=> '2019-04-22',
	                	'money' => 20,
	                	'status' => 1


                	),


                );
               
                $str[$kkk] = "用户昵称,兑奖门店号,核销员,核销员手机号,中奖时间,兑换时间,奖项名称,中奖金额,兑换状态";
                    
                $exl11[$kkk] = explode(',',$str[$kkk]);
                foreach ($rs[$kkk] as $k => $v){
          
                    if (!$v['nickname']) $v['nickname']           = '暂无数据';
                    if (!$v['coder']) $v['coder']                 = '暂无数据';
                    if (!$v['manager']) $v['manager']             = '暂无数据';
                    if (!$v['phone']) $v['phone']                 = '暂无数据';
                    if (!$v['winning_time']) $v['winning_time']   = '暂无数据';
                    if (!$v['exchange_time']) $v['exchange_time'] = '暂无数据';
                    if (!$v['title']) $v['title']                 = '暂无数据';
                    if (!$v['money']) $v['money']                 = '暂无数据';
                   
                    $exl[$kkk][] = array(
                        $v['nickname'],$v['coder'],$v['manager'],$v['phone'],$v['winning_time'],$v['exchange_time'],$v['title'],$v['money'],$ssssd[$v['status']]
                    );
 
                }
 
                exportToExcel('兑奖记录_'.time().$vvv.'.csv',$exl11[$kkk],$exl[$kkk]);
            }
            exit();

 

你可能感兴趣的:(php)