简单快捷实现导出excel表(不用phpexcel插件)
public
function
out2(){
//申明头部,生成excel类型文件
header(
"Content-type:application/vnd.ms-excel"
);
header(
"Content-Disposition:filename=用户信息表.xls"
);
$m
=M(
'member'
);
//获取所有表字段
$_allFields
=
$m
->getDbFields();
//制作表头
echo
"<table style='border:solid 1px #ddd;'>"
;
echo
"<tr style='border:solid 1px #ddd;'>"
;
foreach
(
$_allFields
as
$v
){
echo
"<th>"
.
$v
.
"</th>"
;
}
echo
"</tr>"
;
//查询数据
$_result
=
$m
->select();
foreach
(
$_result
as
$v
){
echo
"<tr style='border:solid 1px #ddd;'>"
;
foreach
(
$_allFields
as
$v1
){
echo
"<td>"
.
$v
[
$v1
].
"</td>"
;
}
echo
"</tr>"
;
}
echo
"</table>"
;
}
发表评论: