Page 1 of 1

what's the best approach for reading and writing MS word doc

Posted: Thu Dec 23, 2010 4:50 am
by epezhman
I'm trying to process MS words doc in PHP. I found some samples which use COM applications for this but not working properly (I get only exceptions and no result)
and I taught it's the version of word on my localhost or my OS so I tried them on with different windows OS and MS word. but same result, since it would be harder to make it work on remote server (the remote server needs to have MS word installed on) so I'm looking for different approach, what you think?? is there nay good one rather than COM applications? have you ever tried? is it possible to write code with other like ASP or java and combine it with PHP? every little piece of advice would be appropriated, thanks :)

Re: what's the best approach for reading and writing MS word

Posted: Mon Dec 27, 2010 9:47 am
by thecodewall
I think this may help.

Code: Select all

<?php
header("Content-type: application/vnd.ms-word");
header("Content-Disposition: attachment;Filename=document_name.doc");

?>


<html>
<head>
<title>Creating word document in PHP</title>
</head>

<body>
hello world
</body>
</html>
It will generate word document.
source: http://thecodewall.blogspot.com/2010/12 ... n-php.html

Re: what's the best approach for reading and writing MS word

Posted: Mon Dec 27, 2010 9:51 am
by Bind
don't forget:

Code: Select all

header("Content-Length: ".filesize($filepath.$filename));