Export HTML to Microsoft Word in 3 steps using PHP

If you want to convert an HTML report to Microsoft Word using PHP then follow the steps below:

1. First download the HTML To Doc class file developed by Harish Chauhan. You will need to save the code in this file to a PHP script.

2. Next generate the HTML code of the table you need to export to Micrsoft Word.

3. Pass the HTML code to the object instantiated from the HTML To Doc class and it will do the rest.

					'. $strHTML .'

// Include the HTML To Doc class file in your PHP script		

// Create the object from the class
$htmltodoc= new HTML_TO_DOC();

// Pass the variable which contains the code to the object. 
// The 3rd parameter forces to download the generated Microsoft Word document.

$htmltodoc->createDoc($strFile, "my_filename.doc", true);

Hope the above helped.

1 Comment

Leave a Reply