public function tui_export(){
if(empty($_GET['userid'])){
showmessage('参数传递错误', '?m=weixin&c=recommend_list&a=index',2000);
}
$table="co_weixin_coupons` as cp LEFT JOIN co_cacos as c ON cp.userid=c.`userid";
$where="cp.type=2 AND cp.userid={$_GET['userid']}";
$infos=$this->coupons_db->select($where,'cp.*,c.cc_name','','cp.c_time DESC','','',$table);
if(empty($infos)){
showmessage('数据为空,不可导出!!!','?m=weixin&c=recommend_list&a=index',1000);
}
$data = array();
foreach($infos as $k=>$v){
$data[$k]['cc_name'] = $v['cc_name'];
$data[$k]['money'] = $v['money']."元";
$data[$k]['c_time'] = date("Y-m-d H:i:s",$v['c_time']);
$data[$k]['status'] = $v['status']==2 ? "已发送红包" : "";
}
$title=array('姓名','红包金额','创建时间','状态');
header("Content-type:application/octet-stream");
header("Accept-Ranges:bytes");
header("Content-type:application/vnd.ms-excel; charset=UTF-8");
header("Content-Disposition:attachment;filename=".iconv("UTF-8", "GB2312//IGNORE",date('Y-M-D',time())."导出方案记录").".xls");
header("Pragma: no-cache");
header("Expires: 0");
//导出xls 开始
if (!empty($title)){
foreach ($title as $k => $v) {
$title[$k]=iconv("UTF-8", "GB2312//IGNORE",$v);
}
$title= implode("\t", $title);
echo "$title\n";
}
if (!empty($refInfo)){
foreach($refInfo as $key=>$val){
foreach ($val as $ck => $cv) {
$refInfo[$key][$ck]=iconv("UTF-8", "GB2312//IGNORE", $cv);
}
$refInfo[$key]=implode("\t", $refInfo[$key]);
}
echo implode("\n",$refInfo);
}
}
php导出Excel表格(无插件)
最新推荐文章于 2019-04-12 14:37:12 发布