Export into MS-Word using PHP -


i want export data ms word file using php on windows , linux operating system. have written following code.

header("content-type: application/vnd.ms-word"); header("content-disposition: attachment;filename=document_name.doc");  echo "<html>"; echo "<meta http-equiv=\"content-type\" content=\"text/html; charset=windows-1252\">"; echo "<body>"; echo '<table cellpadding="0" cellspacing="0" border="0" width="100%">'; echo '<tr><td>test data</td></tr>'; echo '</table>'; echo "</body>"; echo "</html>"; 

i have ms word file without table border when opened ms office 2007. but, if open ms office 2003 have ms word file table border = '1'.

how can fix problem?

you indicating via http headers you're sending word document (mime type applciation/vnd-ms-word), you're outputting html document. if open resulting .doc file in text editor (notepad reasonable choice), you'll see it's html file named .doc. word can parse this, possibilities formatting limited - doesn't understand proper web browser understand.

instead, need convert output word document format. wouldn't recommend doing hand. if you're running on windows, can use com create document. on linux you're out of luck , need use third-party library. have @ zend livedocx framework: http://www.phplivedocx.org/articles/brief-introduction-to-phplivedocx/


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -