Learning & Integrating web technology and code help directory

How to use PHP & Word (Word.Application) - Create Word Document

No comments
How to use PHP & Word (Word.Application) - Create Word Document The Learn / Lutorial / Sctipts php programming how to using  PHP Create word document (.doc)
ShotDev Focus:
- PHP  & Create word document (.doc)
Example
php_create_word.php
  1. <html>  
  2. <head>  
  3. <title>ShotDev.Com Tutorial</title>  
  4. </head>  
  5. <body>  
  6. <?  
  7. $Wrd = new COM("Word.Application");  
  8. $Wrd->Application->Visible = False;  
  9. $Wrd->Documents->Add();  
  10. $DocName = "MyDoc/MyWord.doc";  
  11.   
  12. //$strPath = realpath(basename(getenv($_SERVER["SCRIPT_NAME"]))); // C:/AppServ/www/myphp  
  13.   
  14. $Wrd->Selection->TypeText("Welcome To www.ShotDev.Com");  
  15.   
  16. //$Wrd->ActiveDocument->SaveAs($strPath."/".$DocName);  
  17. $Wrd->ActiveDocument->SaveAs(realpath($DocName));  
  18. $Wrd->Application->Quit;  
  19. $Wrd = null;  
  20. ?>  
  21. Word Created <a href="<?=$DocName?>">Click here</a> to Download.  
  22. </body>  
  23. </html>  
Create a php file and save to path root-path/myphp/
Screenshot
PHP & Create Word Document
.

No comments :

Post a Comment