通常情况下会有二种处理方式: 一种处理方式为:使用PHP访问COM的方式$word = new COM("word.application"); 生成word对象后采用调用com的方法来处理想要的方法。 <?php $word = new COM("word.application"); //To see the version of Microsoft Word, just use $word->Version echo "I'm using MS Word {$word->Version}"; //It's better to keep Word invisible $word->Visible = 0; //Creating new document $word->Documents->Add(); //Setting 2 inches margin on the both sides $word->Selection->PageSetup->LeftMargin = '2"'; $word->Selection->PageSetup->RightMargin = '2"'; //Setup the font $word->Selection->Font->Name = 'Verdana'; $word->Selection->Font->Size = 8; //Write some text $word->Selection->TypeText("Hello, universe!"); //Save the document as DOC file $word->Documents[1]->SaveAs("C:\\apachefriends\\xampp\\htdocs\\com\\a.doc"); //And of course, quit Word $word->quit(); $word->Release(); $word = null; //Give the user a download link echo '<a href="a.doc">Download file as .doc</a>'; ?> 另一种处理方式:从网上找些强人写的纯PHP处理代码,如:PEAR的OpenDecument。 以上想采取什么方式自己找好了。
一种处理方式为:使用PHP访问COM的方式$word = new COM("word.application");
生成word对象后采用调用com的方法来处理想要的方法。
<?php
$word = new COM("word.application");
//To see the version of Microsoft Word, just use $word->Version
echo "I'm using MS Word {$word->Version}";
//It's better to keep Word invisible
$word->Visible = 0;
//Creating new document
$word->Documents->Add();
//Setting 2 inches margin on the both sides
$word->Selection->PageSetup->LeftMargin = '2"';
$word->Selection->PageSetup->RightMargin = '2"';
//Setup the font
$word->Selection->Font->Name = 'Verdana';
$word->Selection->Font->Size = 8;
//Write some text
$word->Selection->TypeText("Hello, universe!");
//Save the document as DOC file
$word->Documents[1]->SaveAs("C:\\apachefriends\\xampp\\htdocs\\com\\a.doc"); //And of course, quit Word
$word->quit();
$word->Release();
$word = null;
//Give the user a download link
echo '<a href="a.doc">Download file as .doc</a>';
?>
另一种处理方式:从网上找些强人写的纯PHP处理代码,如:PEAR的OpenDecument。
以上想采取什么方式自己找好了。