1. php怎么获取word文件的内容
// 建立一个指向新COM组件的索引
$word = new COM(”word.application”) or die(”Can't start Word!”);
// 显示目前正在使用的Word的版本号
//echo “Loading Word, v. {$word->Version}
”;
// 把它的可见性设置为0(假),如果要使它在最前端打开,使用1(真)
// to open the application in the forefront, use 1 (true)
//$word->Visible = 0;
//打?一个文档
$word->Documents->OPen(”d:\myweb\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”);
// 关闭与COM组件之间的连接
$word->Quit();
?>
2. php怎么获取word文档的属性
<?php
// 首先建立一个指向新COM组件的索引
$word = new COM(”word.application”) or die(”Can't start Word!”);
// 显示目前正在使用的Word的版本号
echo “Loading Word, v. {$word->Version}<br>”;
//打开一个文档
$word->Documents->OPen(”d:\myweb\muban.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(”d:/myweb/comtest.doc”);
// 关闭与COM组件之间的连接
$word->Quit();
?>
?>
3. php 怎么实现读取word文档内容,显示到html上面
1. 如果在win可以用com组件读取:
// 建立一个指向新COM组件的索引
$word = new COM("word.application") or die("Can't start Word!");
// 显示目前正在使用的Word的版本号
//echo "Loading Word, v. {$word->Version}
";
// 把它的可见性设置为0(假),如果要使它在最前端打开,使用1(真)
// to open the application in the forefront, use 1 (true)
//$word->Visible = 0;
//打?一个文档
$word->Documents->OPen("d:\a.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");
// 关闭与COM组件之间的连接
$word->Quit();
2. linux可用antiword插件去实现
4. 用php 读取word 文档内容 比如:word文档为试题等等
可以的话你把文档另存为csv格式<?php$row =="" 1;$handle="fopen("test.csv","r");while" ($data="fgetcsv($handle," 1000,="" ","))="" {="" $num="count($data);" echo="" "="" $num="" fields="" in="" line="" $row:="" \n";="" $row++;="" for="" ($c="0;" $c="">?php$row>< $num;="" $c++)="" {="" echo="" $data[$c]="" .="" "\n";="" }}fclose($handle);?="">。
转载请注明出处51数据库 » php怎么读取word文档