Forum Moderators: coopster
I'm trying to use PHP to create a word document on the fly.
I've read about various approaches, and have finally found one I feel is the fastest with the most options.
It seems to be working fine (lots of tweaks still left to work out), but there is one issue that is driving me crazy.
Even though I'm using PHP to send out the correct header, when the client tries to save an opened word file, they are prompted by default to save it in HTML, not as a word doc.
What should I do?
Thanks.
CODE:
<?php
header("Content-Type: application/msword");
header("Content-Disposition: attachment; filename=\"file.doc\"");
?>
<html xmlns:w="urn:schemas-microsoft-com:office:word">
<head>
<title><?php echo(rand());?></title>
<xml>
<o:DocumentProperties>
<o:Author><?php echo(rand());?></o:Author>
</o:DocumentProperties>
</xml>
<style>
h1{font:16pt arial,sans-serif}
p{font:12pt arial,sans-serif}
</style>
</head>
<body>
<div>
<h1><o:p><?php echo(rand());?></o:p></h1>
<p><o:p><?php echo(rand());?></o:p></p>
</div>
</body>
</html>
[edited by: Jeremy_H at 3:43 pm (utc) on Aug. 3, 2006]
Since it is rather easy to create a Word Document (via the header), does anybody know of a layout scheme other than HTML I can use to create a word document?
For example, does word have its own markup language I could use to create a true, non web-based word document?
Thanks