在PHP中将MS Word文档转换为html [英] Converting MS Word document to html in php

查看:445
本文介绍了在PHP中将MS Word文档转换为html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将Microsoft Word文档转换为PHP中的html?我正在使用Windows,并且听说COM包已经这样做了。 PHP的COM扩展

PHP网站的使用示例

 <?php 
//起始字
$字=新COM (word.application)或死(无法实例化Word);
回显加载的Word,版本{$ word->版本} \ n;

//将它带到前面
$ word-> Visible = 1;

//打开一个空文档
$ word-> Documents-> Add();

//做一些奇怪的事情
$ word-> Selection-> TypeText(This is a test ...);
$ word-> Documents [1] - > SaveAs(Useless test.doc);

//结束字
$ word-> Quit();

//释放对象
$ word = null;
?>


How can I convert a Microsoft Word document to html in php? I am using windows, and heard that the COM package does it.

解决方案

See the COM extension of PHP.

Example of the usage by the PHP site:

<?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;
?>

这篇关于在PHP中将MS Word文档转换为html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆