求助大神,用PHP导出excel文件都是乱码

浏览:10141 发布日期:2014/10/04 分类:求助交流
<?php

class TestAction extends Action{
//导出Excel,导出的数据为本月至现在时间的数据

//导出本月预约但已流失病人
public function ifaway(){
if($_SESSION['level']==9||$_SESSION['level']==99){
$month=mktime(0,0,0,date('m'),1,date('Y'));
$time=time();
$arr=M('order')
->join("tp_user u on tp_order.uid=u.uid")
->join("tp_area a on tp_order.aid=a.aid")
->join("tp_disease d on tp_order.did=d.did")
->join("tp_source s on tp_order.sid=s.sid")
->join("tp_source f on tp_order.fid=f.sid")
->where('appointtime>='.$month.' and appointtime<='.$time.' and ifaway=1')
->field("tp_order.oid,tp_order.num,tp_order.name,tp_order.sex,tp_order.age,tp_order.tel,a.aname,d.dname,tp_order.appointtime,tp_order.inputtime,u.uname,s.sname sname,f.sname fname,tp_order.ifreturn,tp_order.return_content")
->select();
foreach($arr as $k=>$v){
if($v['sex']==1){
$arr[$k]['sex']='男';
} else{
$arr[$k]['sex']='女';
}
if($v['ifreturn']==0){
$arr[$k]['ifreturn']='否';
} else{
$arr[$k]['ifreturn']='是';
}
$arr[$k]['appointtime']=date('Y-m-d',$v['appointtime']);
$arr[$k]['inputtime']=date('Y-m-d',$v['inputtime']);
}
$title=array('编号','预约号','姓名','性别','年龄','电话','地址','咨询类型','预约日期',' 登记日期',' 登记客服','来源方式','来源载体','是否回访','回访内容');
$filename=date("Y-m")."月流失病人";
exportexcel($arr,$title,$filename);
}else{
$this->error("你不是管理员---无权限操作");
}
}
//导出本月就诊病人
public function visit(){
if($_SESSION['level']==9||$_SESSION['level']==99){
$month=mktime(0,0,0,date('m'),1,date('Y'));
$time=time();
$arr=M('order')
->join("tp_user u on tp_order.uid=u.uid")
->join("tp_area a on tp_order.aid=a.aid")
->join("tp_disease d on tp_order.did=d.did")
->join("tp_source s on tp_order.sid=s.sid")
->join("tp_source f on tp_order.fid=f.sid")
->join("tp_expert e on tp_order.eid=e.eid")
->where('visittime>='.$month.' and visittime<='.$time.' and visit=1')
->field("tp_order.oid,tp_order.num,tp_order.name,tp_order.sex,tp_order.age,tp_order.tel,d.dname,a.aname,tp_order.appointtime,tp_order.inputtime,u.uname,f.sname fname,s.sname sname,tp_order.visittime,e.ename")
->select();
foreach($arr as $k=>$v){
if($v['sex']==1){
$arr[$k]['sex']='男';
} else{
$arr[$k]['sex']='女';
}
$arr[$k]['appointtime']=date('Y-m-d',$v['appointtime']);
$arr[$k]['inputtime']=date('Y-m-d',$v['inputtime']);
$arr[$k]['visittime']=date('Y-m-d',$v['visittime']);
}
$title=array('编号','预约号','姓名','性别','年龄','电话','地址','咨询类型','预约日期',' 登记日期',' 登记客服','来源方式','来源载体','就诊日期','就诊专家');

$filename=date("Y-m")."月就诊病人";
exportexcel($arr,$title,$filename);
}else{
$this->error("你不是管理员---无权限操作");
}

}

}
?>
求大神帮我看看,导出的查询数据在excel表里全是乱码
最佳答案
评论( 相关
后面还有条评论,点击查看>>