tp导出excel
//数据导出
protected function dao($db,$where,$join,$field){
$data = M($db)->join($join)->where($where)->field($field)->order('stime desc')->select();
date_default_timezone_set("PRC");
Header("Content-Type: application/vnd.ms-excel; charset=UTF-8");
Header("Accept-Ranges:bytes");
Header("Content-Disposition:attachment;filename=".date('YmdHis').".xls");
Header("Pragma: no-cache");
Header("Expires: 0");
$tx='配送信息';
$str.=$tx."\n\n";
$str.= "ID"."\t";
$str.= "微信流水号"."\t";
$str.= "微信手机号"."\t";
$str.= "收货人"."\t";
$str.= "联系方式"."\t";
$str.= "收货地址"."\t";
$str.= "参团类型"."\t";
$str.= "预约成功时间"."\t";
$str.= "参与人数"."\t";
$str.= "备注"."\t\r\n";
$info = iconv("UTF-8","GBK",$str);
echo $info;
$type = array('团员','团长');
foreach($data as $arr){
$str2.= trim(iconv("UTF-8","GBK",$arr['id']))."\t";
$str2.= mb_convert_encoding('`'.$arr['wxoid'],"GBK","UTF-8")."\t";
$str2.= trim(iconv("UTF-8","GBK",$arr['wphone']))."\t";
$str2.= trim(iconv("UTF-8","GBK",$arr['name']))."\t";
$str2.= trim(iconv("UTF-8","GBK",$arr['phone']))."\t";
$str2.= trim(iconv("UTF-8","GBK",$arr['city'].$arr['address']))."\t";
$str2.= trim(iconv("UTF-8","GBK",$type[$arr['type']]))."\t";
$str2.= mb_convert_encoding(date("Y-m-d H:i:s",$arr['stime']),"GBK","UTF-8")."\t";
$str2.= trim(iconv("UTF-8","GBK",$arr['nowman']))."\t";
$str2.= trim(iconv("UTF-8","GBK",$arr['remark']))."\t\r\n";
}
echo $str2;
}