以下这段代码,可以打开word文档并 编辑 指定字符串,但请问有人知道怎么在 保留 原有word的 样式 的情况下替换吗? note: $test= $word-activedocument-content-text; 这句语句获取了word的文档内容,但是并没有获取word的格式。例如,加粗、斜体、下划线
以下这段代码,可以打开word文档并编辑指定字符串,但请问有人知道怎么在保留原有word的样式的情况下替换吗?
note:$test= $word->activedocument->content->text; 这句语句获取了word的文档内容,但是并没有获取word的格式。例如,加粗、斜体、下划线等样式都没有了。
$word = new com(”word.application”) or die(”can't start word!”);
$word->documents->open(”d:\web\muban.doc”);
$test= $word->activedocument->content->text;
echo $test;
echo “
”;
$test=str_replace(””,”这是变量”,$test);
echo $test;
$word->documents->add();
$word->selection->typetext(”$test”);
$word->documents[1]->saveas(”d:/myweb/comtest.doc”);
$word->quit();
?>