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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
epezhman
Forum Newbie
Posts: 4
Joined: Wed Dec 22, 2010 9:31 am

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

Post 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 :)
thecodewall
Forum Commoner
Posts: 33
Joined: Sun Dec 26, 2010 8:37 am

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

Post 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
Bind
Forum Contributor
Posts: 102
Joined: Wed Feb 03, 2010 1:22 am

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

Post by Bind »

don't forget:

Code: Select all

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