/*导出xls用户个人信息*/
function export(){
header("Content-type:application/octet-stream");
header("Accept-Ranges:bytes");
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:attachment;filename=用户信息表".date("Y-m-d").".xls");
header("Pragma: no-cache");
header("Expires: 0");
//导出xls 开始
$tag0 = iconv("UTF-8", "GB2312",'用户ID');
$tag1 = iconv("UTF-8", "GB2312",'用户名');
$tag2 = iconv("UTF-8", "GB2312",'待领取');
$tag3 = iconv("UTF-8", "GB2312",'奖金总数');
$tag4 = iconv("UTF-8", "GB2312",'开户行');
$tag5 = iconv("UTF-8", "GB2312",'开户城市');
$tag6 = iconv("UTF-8", "GB2312",'开户行地址');
$tag7 = iconv("UTF-8", "GB2312",'银行卡号');
$tag8 = iconv("UTF-8", "GB2312",'持卡人姓名');
echo "$tag0\t$tag1\t$tag2\t$tag3\t$tag4\t$tag5\t$tag6\t$tag7\n";
////查询的一张表
//$arr=M ('textpage')->field('username,count(id) as allcount,sum(price) as allprice ')->group('username')->select();
$field="crowd_textpage.tid,crowd_textpage.username,users.bankName,users.city,users.bankAddress,
users.bankCard,users.bankUsr,count(crowd_textpage.id) as allcount,sum(crowd_textpage.price) as allprice";
$arr = M ('textpage')->field($field)
->join('crowd_user as users ON crowd_textpage.username=users.username')
->group('crowd_textpage.username')
->select();
//dump(M ('textpage')->getLastSql());die;
foreach($arr as $key=>$val){
//$date = date('Y-m-d',$val['pay_time']);
$tid = iconv("UTF-8", "GB2312", $val['tid']);
$tid=$tid?$tid:'-';
$username = iconv("UTF-8", "GB2312", $val['username']);
$username=$username?$username:'-';
$allcount = iconv("UTF-8", "GB2312", $val['allcount']);
$allcount=$allcount?$allcount:'-';
$allprice = iconv("UTF-8", "GB2312", $val['allprice']);
$allprice=$allprice?$allprice:'-';
$bankName = iconv("UTF-8", "GB2312", $val['bankName']);
$bankName=$bankName?$bankName:'-';
$city = iconv("UTF-8", "GB2312", $val['city']);
$city=$city?$city:'-';
$bankAddress = iconv("UTF-8", "GB2312", $val['bankAddress']);
$bankAddress=$bankAddress?$bankAddress:'-';
$bankCard = iconv("UTF-8", "GB2312", $val['bankCard']);
$bankCard=$bankCard?$bankCard:'-';
$bankUsr = iconv("UTF-8", "GB2312", $val['bankUsr']);
$bankUsr=$bankUsr?$bankUsr:'-';
echo "$tid\t$username\t$allcount\t$allprice\t$bankName\t$city
\t$bankAddress\t'$bankCard\t$bankUsr\n";
}
} |