Reputation: 1911
I've already got the functionality to print pdf reports and bills in my application, but now I need to also be able to export in .doc format. I'm using TCPDF's writeHTML function to write and format the pdf files, and I was wondering if there's a way to do the same for .doc files.
Upvotes: 2
Views: 2356
Reputation: 34857
This is pretty straight forward. A .doc file can just contain HTML. If you pass along the Word header, you can just start printing HTML. So, for example:
<?php
header("Content-Type: application/vnd.ms-word");
print "<table border=\"1\"><tr><td><b>field1</b></td><td><b>field2</b></td></tr>";
print "<tr><td>value1 </td><td bgcolor=\"#137799\">value2 in blue cell bakground</td></tr></table>";
?>
Source: here (verified it to be working).
Upvotes: 2