码迷,mamicode.com
首页 > Web开发 > 详细

php学习笔记之将word文档转化为HTML文件

时间:2015-05-28 21:31:27      阅读:157      评论:0      收藏:0      [点我收藏+]

标签:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>将word文档转化为HTML文件</title>
</head>

<body>
<p>
  <?PHP

function wordTohtml($wfilepath) 
  { 
  $word=new COM("Word.Application") or die("无法打开 MS Word"); 
  $word->visible = 1 ; 
  $word->Documents->Open($wfilepath)or die("无法打开这个文件"); 
  $htmlpath = substr($wfilepath,0,-4); 
  $word->ActiveDocument->SaveAs($htmlpath,8);  
  $word->quit(0); 
  return $htmlpath;
  }  
$str1 = "test";
$w="E:/AppServ/www/yougan/" . $str1 . ".doc"; 
$path = wordTohtml($w) . ".htm"; 
echo $path . "<br/>";
print( "Word转html完成!" );
$str2 = $str1 . ".htm";
echo "<script>window.location.href='". $str2 . "';</script>";

?>
</body>
</html>

php学习笔记之将word文档转化为HTML文件

标签:

原文地址:http://blog.csdn.net/qiaoruozhuo/article/details/46128671

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!