我已经建立了一个HTML表并在其中加载数据。我想要做的是,基于包含数据的表创建(或转换)到excel并将excel文件保存在项目目录中。
这是我的HTML表
<table class='tblNemoList' border='1' cellpadding='3' cellspacing='0' width='100%' style='-fs-table-paginate: paginate;'>
$thChanges
$trChanges
$thMissing
$trMissing
$thNew
$trNew
</table>
";
$strFilename = "FIM_KnowMore_Report_$DT";
excel转换在这里
header("Pragma: no-cache");
header("Expires: 0");
header("Content-type: application/x-msdownload");
header("Content-Disposition: attachment; filename=". $strFilename .".xls"); //gets set inside the report.rpt.php
file_put_contents($strFilename, $strBody);
我缺少将其保存在目录中的代码。
PHPExcel是一个用php创建和处理excel文件的伟大库。试试吧。
PHPExcel on GitHub