How to convert html to word /excel / powerpoint with PHP ?
Try the following PHP classes:
I only used PHPExcel so far but it worked great and is easy to learn. Since all classes are from the same company I assume that they should fit your needs as well.
I think the easiest way to generate DOC files with PHP is using the Zend Framework component phpLiveDocx. You can load Word or Open Office templates, merge textual data and save the final document to a number of formats, such as DOC, DOCX, RTF and PDF.
I agree that @Nick answer is correct, but you do not need an external tool to do what you need, at least not for Word.
To generate a Word document simply add this code at the top of the page you want to convert.
<?php
header("Content-Type: application/vnd.ms-word");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("content-disposition: attachment;filename=MyReport.doc");
?>
For Excel I found this (did not test):
<?php
header("Content-Type: application/vnd.ms-excel; charset=utf-8");
header("Content-Disposition: attachment; filename=abc.xls");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
?>