您的位置:首页 > 编程语言 > PHP开发

php解析doc格式word文件的另一种方法

2014-04-02 10:45 645 查看
原理是用php调用外部工具实现,用到的工具是antiword 

步骤1:下载解压antiword后,将antiword文件夹放到一个系统盘根目录下

步骤2:增加环境变量,我编写了一个批处理脚本,如下:

@echo off
:: place为antiword所在盘符
set place="e:"
:: 设置环境变量HOME
wmic ENVIRONMENT create name="HOME",username="<system>",VariableValue=%place%
:: 添加Path
wmic ENVIRONMENT where "name='path' and username='<system>'" set VariableValue="%path%;%HOME%"
pause


步骤3:编写php脚本

<?php
$file = "e:\antiword\ccc.doc";
$content = shell_exec("e:\antiword\antiword –f $file"); //e盘为antiword软件所在的盘
echo $content;
?>


转载请注明出处http://blog.csdn.net/iluckyning/article/details/22783625
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息