$rows = AchivmentInserModel::where('title',$res->title)->get()->toArray();
$_pre = array(
"username" => "姓名",
"ticket" => "准考证",
"create_data" => "获取时间",
"mobile" => "手机号",
"title" => "专题名称",
);
$date = date("YmdHis");
$content = $this->getXLSFromList($_pre,$rows);
header("Content-type:application/vnd.ms-execl;charset=gb2312");
header("Content-Disposition:attactment;filename=成绩查询信息表".$date.".xls");
header("Pragma: no-cache");
header("Expires: 0");
echo $content;
exit;
function getXLSFromList($pres,$lists){
$keys=array_keys($pres);
$content="";
$content.="<table border='1'><tr>";
foreach($pres as $_pre){
$content.="<td>$_pre</td>";
}
$content.="</tr>";
foreach($lists as $_list){
$content.= "<tr>";
foreach($keys as $key){
$content.= "<td style='vnd.ms-excel.numberformat:@'>".$_list[$key]."</td>";
}
$content.="</tr>";
}
$content.="</table>";
return $content;
}
|