javascript - How to create an excel file based on the HTML table and save it in the project directory
990
I have build an HTML table and load data in it. What I want to do is, based on that table which contains data create(or convert) it to excel and save the excel file in the project directory.
Here is my HTML Table
<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";
And the excel conversion is here
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);
I am missing the code to save it in a directory. Can you please help ?
Answer
Solution:
PHPExcel is a great library for creating and handling excel files with php. give it a try.
PHPExcel on GitHub