php table如何转excel

PHPz
发布: 2023-03-05 22:52:02
原创
2706 人浏览过

php table转excel的实现方法:首先定义一个“excelData”方法;然后设置表格数据、head以及表头;最后通过“excelData($dataResult, $titlename...;)”方式生成excel文件即可。

php table如何转excel

推荐:《PHP视频教程

php 根据html table生成excel文件

\r\n\r\n\r\n
\r\n"; $str .= "" . $titlename . "
"; $str .= $title; foreach ($datas as $key => $rt) { $str .= ""; foreach ($rt as $k => $v) { $str .= ""; } $str .= "\n"; } $str .= "
{$v}
"; echo $str; header("Content-Type: application/vnd.ms-excel; name='excel'"); header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=" . $filename); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Pragma: no-cache"); header("Expires: 0"); exit($str); } $dataResult = array(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11), array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)); $headTitle = "XX保险公司 优惠券赠送记录"; $title = "优惠券记录"; $headtitle = "{$headTitle}"; $titlename = " 合作商户 会员卡号 车主姓名 手机号 车牌号 优惠券类型 优惠券名称 优惠券面值 优惠券数量 赠送时间 截至有效期 "; $filename = $title . ".xls"; excelData($dataResult, $titlename, $headtitle, $filename); echo 'success';
登录后复制

以上是php table如何转excel的详细内容。更多信息请关注PHP中文网其他相关文章!

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!