下面我们利用windown com组件来实现doc文件一些简单的操作,希望对你有所帮助,实例代码如下:
- <?php
-
- $word = new COM("word.application") or die("Can't start Word!");
-
-
-
-
-
- echo $word->Version;
-
- $word->Documents->OPen("C:wampwwwtest1.doc");
-
-
- $test= $word->ActiveDocument->content->Text;
-
- echo $test;
- echo '<br>';
-
- $test=str_replace('<{变量}>','这是变量',$test);
- echo $test;
- $word->Documents->Add();
-
- $word->Selection->TypeText('$test');
-
- $word->Documents[1]->SaveAs("C:wampwwwtest2.doc");
-
- $word->Quit();
- ?>
|