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 ?

156

Answer

Solution:

PHPExcel is a great library for creating and handling excel files with php. give it a try.

PHPExcel on GitHub

People are also looking for solutions to the problem: PHP If entire word is within string

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.