怎样用PHP读取一个word文档内容并在浏览器中显示出来?

如题,高分求解。先给20分,如果可行,立即提分到100。
网上的哪些方法通通都不行,都是前台打开的坑爹方法
我的qq:592760127
可以直接发qq邮箱
然后在回答中告知邮件标题

第1个回答  2018-06-13
<?
// 建立一个指向新COM组件的索引
$word = new COM(”word.application”) or die(”Can't start Word!”);
// 显示目前正在使用的Word的版本号
//echo “Loading Word, v. {$word->Version}<br>”;
// 把它的可见性设置为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 “<br>”;
第2个回答  2018-03-30
phpword
$word = \PhpOffice\PhpWord\IOFactory::load($file);
第3个回答  2018-02-23
新版的phpword早就可以读Word了
第4个回答  2014-10-19
<?php
//读文件
//打开文件
$file_path="text.txt";
//该函数返回一个指向文件袋指针
//先判断文件是否存在
if(file_exists($file_path)){
//打开文件
$fp=fopen($file_path,"a+");
//读文件 并输出 ps:不换行输出
$content=fread($fp,filesize($file_path));
echo"content is:";
//在默认情况下得到的内容不会换行
//网页不认\r\n是换行符 方法:\r\n---》<br> 调用函数str_replace
$content=str_replace("\r\n","<br>", $content);
echo$content;
}else{
echo"file does not exist!";
}
fclose($fp);

//第二种读取方式一个函数
$file_path="text.txt";
$content=file_get_contents($file_path);
$content=str_replace("\r\n","<br>", $content);
echo$content;

//第三中读取方式 循环读取(对付大文件)
$fp=fopen($file_path,"a+");
//一次读取1024个字节
$buffer=1024;
$str="";
//一边读,一边判断是否到达文件末尾
while(!feof($fp)){
$str=fread($fp,$buffer);
$str=str_replace("\r\n","<br>", $str);
echo$str;
}
fclose($fp);
第5个回答  2014-10-15
//这是php官方手册中的例子,你可以参考下,或许对你有所帮助

// starting word
$word = new
COM (
"word.application" ) or die( "Unable to instantiate Word" );
echo "Loaded Word, version { $word -> Version
} \n"
;

//bring it to front
$word ->
Visible = 1 ;

//open an empty document
$word ->
Documents -> Add
();

//do some weird stuff
$word ->
Selection -> TypeText
( "This is a test..." );
$word
-> Documents [
1 ]->
SaveAs (
"Useless test.doc" );

//closing word
$word ->
Quit ();

//free the object
$word =
null ;
相似回答