首页 >后端开发 >php教程 >php学习笔记之将word文档转化为HTML文件

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

WBOY
WBOY原创
2016-06-23 13:33:49786浏览

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>将word文档转化为HTML文件</title><p>  <?PHPfunction 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>";?></p>

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn