sushant.d84 Posted October 16, 2008 Share Posted October 16, 2008 Hi, I am looking for any Third Party Tool. I am in need to generate the MS-WORD using PHP. First I need to display in Web Page then there should be a button which say "Export to Word". The word document should have header and footer too. Can Any body suggest me. Please let me know your views. THanks and ADvance Sushant Danekar Quote Link to comment https://forums.phpfreaks.com/topic/128687-php-wth-ms-word-working/ Share on other sites More sharing options...
redarrow Posted October 16, 2008 Share Posted October 16, 2008 Here a good example off creating .doc only this will do have a go.. <?php // created via redarrow...... if(isset($_POST['submit'])){ $new_doc=trim($_POST['new_doc']); $file_name=trim($_POST['file_name']); $cheek=$_POST['cheek']; $error=$_POST['error']; if( empty($new_doc) && empty($file_name) ){ $error='FALSE'; } $cheek=substr($file_name,-4); if($cheek !='.doc') { $error='FALSE'; } $x=glob("*.*"); if(in_array($file_name,$x)){ $error='FALSE'; } $fh=fopen($file_name, 'w+'); fwrite($fh, $new_doc); @fclose($fh); } if($error=='FALSE'){ echo "<center>PLEASE TRY AGIN THERE WAS A PROBLAM! <br><br> (1) Make sure the name of the file is a .doc. <br> (2) Make sure you fill in all the form. <br> (3) An error could be same file name, try another. <br> </center>"; } ?> <center> <form method="POST" action="<?php $_SERVER['PHP_SELF']; ?>"> <br> <br> Please name the file .doc <br> <br> <input type="text" name="file_name"> <br> <br> Please write your text <br> <br> <textarea name="new_doc" cols="30" rows="20"> </textarea> <br> <br> <input type="submit" name="submit" value="Export to Word"> <br><br> </form> </center> Quote Link to comment https://forums.phpfreaks.com/topic/128687-php-wth-ms-word-working/#findComment-667465 Share on other sites More sharing options...
DarkWater Posted October 16, 2008 Share Posted October 16, 2008 Except for the fact that your piece of code actually doesn't write anything of use to a .doc file other than a bit of text, your HTML is really bad. =/ .doc requires the COM extension (as far as I know, I've never dabbled with MSOffice documents) or some other third party class in order to actually write meaningful .doc files. Google it. Also, shouldn't this be in PHP Help? Quote Link to comment https://forums.phpfreaks.com/topic/128687-php-wth-ms-word-working/#findComment-667480 Share on other sites More sharing options...
Daniel0 Posted October 16, 2008 Share Posted October 16, 2008 redarrow, .doc files are not plaintext. See: http://download.microsoft.com/download/0/B/E/0BE8BDD7-E5E8-422A-ABFD-4342ED7AD886/Word97-2007BinaryFileFormat(doc)Specification.pdf Quote Link to comment https://forums.phpfreaks.com/topic/128687-php-wth-ms-word-working/#findComment-667482 Share on other sites More sharing options...
corbin Posted October 17, 2008 Share Posted October 17, 2008 Whoa 210 pages. Fun! Quote Link to comment https://forums.phpfreaks.com/topic/128687-php-wth-ms-word-working/#findComment-667700 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.