Simple PHP operation word file implementation code_PHP tutorial

WBOY
Release: 2016-07-20 11:09:51
Original
893 people have browsed it

Below we use the winddown com component to implement some simple operations on doc files. I hope it will be helpful to you.

Below we use the winddown com component to implement some simple operations on doc files. I hope it will be helpful to you.

// Create an index pointing to the new COM component
$word = new COM("word.application") or die("Can't start Word!");
// Display the version number of Word currently being used
//echo “Loading Word, v. {$word->Version}
”;
// Set its visibility to 0 (false). To open the application in the forefront, use 1 (true)
//$ word->Visible = 0;
echo $word->Version;
//Echo a document
$word->Documents->OPen("C:wampwwwtest1.doc") ;
//Read document content

$test= $word->ActiveDocument->content->Text;

echo $test;

echo '< ;br>';
//Replace the variables that need to be replaced in the document
$test=str_replace('<{variable}>','This is a variable',$test);
echo $test;
$word->Documents->Add();
// Add text to the new document
$word->Selection->TypeText('$test') ;
//Save the document in the directory
$word->Documents[1]->SaveAs("C:wampwwwtest2.doc");
//Close the connection with the COM component Connect
$word->Quit();
?>


http://www.bkjia.com/PHPjc/444760.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/444760.htmlTechArticle Below we use the winddown com component to implement some simple operations on doc files. I hope it will be helpful to you. Below we use the winddown com component to implement some simple operations on doc files. I hope...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!