$file_type = "vnd.ms-excel"; // excel表头固定写法
$file_ending = "xls"; // excel表的后缀名
header("Content-Type: application/$file_type");
header("Content-Disposition: attachment; filename=list.$file_ending"); // agentfile到处的表名
header("Pragma: no-cache"); // 缓存
header("Expires: 0");
echo mb_convert_encoding("姓名","GBK","utf-8")." \t ".mb_convert_encoding("年龄","GBK","utf-8")." \t ".mb_convert_encoding("时间","GBK","utf-8");
print("\n");
//循环数据~ 换行就print("\n");
exit;
--------------------------
这样就好了。
基本上,定义好mimetype,输出内容。就会自动下载成excel了~不要用下载工具哦。
php mysql数据导出excel
最新推荐文章于 2021-08-14 18:05:57 发布
648

被折叠的 条评论
为什么被折叠?



