Friday, April 3, 2009

Create Word Document Using PHP

Here is the example of creating word document using php.
$wordObj = new COM("word.application") or die ("Could not create an instance of word");
echo "Version : {$wordObj->version}";
$wordObj->visible = 1;
$wordObj->Selection->TypeText("Hello World.."); // add text here
$wordObj->Documents[1]->SaveAs("sample.doc"); // save location
$wordObj->Release(); //free object
$wordObj = null;

1 comment:

  1. Is there any other way to make doc file without using component..