Creating word file using PHP com
Creating word file using PHP com
<?php
//allow com extension
ini_set("com.allow_dcom","true");
// starting word
$word = new COM("word.application") or die("Unable to instantiate Word");
echo "Loaded Word, version {$word->Version}\n";
//bring it to front
$word->Visible = 1;
//open an empty document
$word->Documents->Add();
//do some weird stuff
$word->Selection->TypeText("This is a Dinesh Kumar Shrivastava");
$word->Documents[1]->SaveAs("C:\Downloads\mydoc.docx");
//closing word
$word->Quit();
//free the object
$word = null;
?>
We can also create files(any format) using the touch function in PHP.
<?php touch("test.docx"); ?>
Post a Comment