- $word = new \COM('word.application') or die("Can't start Word!");
- $str = str_replace( 'Application\Home\Controller', 'Uploads\\',__DIR__);
- //$filePath 上传后的文档地址
- $wfilepath = $str.$filePath;
- //打?一个文档 要用绝对地址
- $word->Documents->OPen($wfilepath) or die("文档打开失败!");
- //读取文档内容 (不能读取图片)
- //$test= $word->ActiveDocument->content->Text;
- //获取链接地址
- //echo $url;
- $htmlpath= substr($wfilepath,0,-5);
- $url = $_SERVER['HTTP_HOST'];
- $url = $url.$_SERVER['PHP_SELF'];
- $url = dirname($url);
- // dump($htmlpath);die;
- //保存为HTML格式
- $word->ActiveDocument->SaveAs($htmlpath,8);
- $html = 'Uploads/' . $filePath;
- $htm = U(str_replace(substr($html, -5),'',$html));
- // dump($htm);die;
- /*$hrefs = str_replace('/index.php','',$htm);
- $href = str_replace('.html', '.htm', $hrefs);*/
- $word->quit(0);
win环境下word生成html
最新推荐文章于 2024-02-02 10:19:12 发布