您现在的位置是:网站首页>>PHP>>php
php 实现将html中的table表格中的内容导出为Excel
发布时间:2018-12-28 10:04:12作者:wangjian浏览量:578点赞量:0
php实现将html内的table标签内的表格信息导出为Excel/**
* 导出excel
* @param $strTable table表格中的html信息
* @param $filename 文件名
*/
public function ExcelInfo($strTable,$filename)
{
header("Content-type: application/vnd.ms-excel");
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=".$filename.".xls");
header('Expires:0');
header('Pragma:public');
echo $str = '
';exit($str);
}
这里注意下:如果你使用的是a标签通过ajax与后端通信的话,这样是无法导出Excel的,这时候,你需要通过a标签点击事件模拟form表单提交事件
例://excelData为a表单点击触发的事件
function excel