Jump to content

PHP WTH MS-WORD WORKING


sushant.d84

Recommended Posts

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

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.