如何创build基于HTML表格的Excel文件并将其保存在项目目录中
我已经build立了一个HTML表格并在其中加载数据。 我想要做的是,基于包含数据的表创build(或转换)为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创build和处理excel文件的好库。 试一试。
PHPExcel在GitHub上