code for reading and writing WORD documents in word2003 simplified Chinese version in PHP

WBOY
Release: 2016-07-29 08:37:46
Original
1458 people have browsed it

Copy the code The code is as follows:


// 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), if you want to open the application in the front, use 1 (true)
// to open the application in the forefront, use 1 (true)
//$word->Visible = 0;
// Open a document
$word->Documents->OPen(”d:mywebmuban.doc”);
//Read the document content
$test= $word->ActiveDocument->content->Text ;
echo $test;
echo “
”;
//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 a new document
$word->Selection->TypeText("$test");
//Save the document in the directory
$word->Documents[1]->SaveAs(”d:/myweb/comtest.doc”);
// Close the connection with the COM component
$word- >Quit();
?>

The above introduces the code for reading and writing WORD documents in PHP for the simplified Chinese version of word2003, including the content of the simplified Chinese version of word2003. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
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