• 实现word在线预览 有php的写法 也有插件似


    <?php
    //header("Content-type:text/html;charset=utf-8");
    //word转html 展示
    $lj=$_GET['file'];//传来的是文件位置 具体看自己的传值 upload/user/20170306/20170306xgtlne.doc
     $lj=str_replace("/",'\',$lj);//把路径改为号 例如 uploaduser2017030620170306xgtlne.doc
    
    function word2html($wordname,$htmlname)
    {
       $word = new COM("word.application") or die("Unable to instanciate Word");
       $word->Visible = 1;
       $word->Documents->Open($wordname);
       $word->Documents[1]->SaveAs($htmlname,8);
       $word->Quit();
       $word = null;
    unset($word);
    
    }
    //服务器或本地的word具体位置 例如'D:phpStudyWWWGongshuUnion.uploaduser2017030620170306xgtlne.doc'
    $address='D:phpStudyWWWGongshuUnion\';
    word2html($address.$lj,$address.$lj.".html");
    //跳转时可以在后最加上.html 
    //例如  $url=  http://localhost/GongshuUnion/upload/user/20170306/20170306xgtlne.doc.html
    //我这里一共传了两个值 一个是 $_GET['file'] = upload/user/20170306/20170306xgtlne.doc 
    //另一个是$_GET['url']=http://localhost/GongshuUnion/upload/user/20170306/20170306xgtlne.doc.html
    $url= $_GET['url']; 
    Header("Location:$url");
    ?>

    本地最好要支持office word 组件不然不能完美转换,wps没有api。

    先确认com模块是不是开启,phpinfo里面如果有com_dotnet模块,说明已开启,如果没有,修改php.ini,

    1
    com.allow_dcom = true

      前面的注释去掉,重启就OK了,php官方网站说,php5.4.5之前,com模块是内置的,其实也不一定全是,官网下的php 5.3.39,com模块就没有内置。

    如果不是内置模块的话,php.ini加上,前提你的ext文件夹下,有该扩展

    1
    extension=php_com_dotnet.dll

      然后重启就OK了

     部分代码转载(http://www.jb51.net/article/78492.htm

    最近又找了几个方法我把他写在这里是实现在线预览office的

    复制代码
     <a href="http://ow365.cn/?i=12592&furl=http://abc.qybk.cn/{$file.file}" target="_blank">查看</a>    //一天免费查看500次 优点速度快  非会员                     
    
    <a href="http://api.idocv.com/view/url?url=http://abc.qybk.cn/{$file.file}" target="_blank">查看</a>//每个文件能看只能看5次 好像没有每次限制就是有每个文件查看次数限制? 非会员
    
    <a href="http://view.officeapps.live.com/op/view.aspx?src=http://abc.qybk.cn/{$file.file}" target="_blank">查看</a> //微软官方自带的
    复制代码

    主要实现方法自己看我发的链接    除了第一个要注册试用 其他全部可以免费使用

    第一个超链接http://www.officeweb365.com/  furl=是自己域名下文件的地址

    第二个超链接https://www.idocv.com/  url=是自己域名下文件的地址

    第三个使用微软提供的Office Online平台只需要一个网址即可在线查看Xls,doc,PPT等文档

    这些都可以实现Xls,doc,PPT等文档在线预览
  • 相关阅读:
    android-support-v4.jar 免积分下载
    Android canvast View 代码实例
    Android recording 录音功能 简单使用小实例
    android progressdialog 对话框试用实例
    Android 视频 教程 源码 电子书 网址
    android Notification
    Zookeeper 基本应用及盲点
    Mysql 死锁分析学习
    Mysql 学习总结
    数据库事务的本质
  • 原文地址:https://www.cnblogs.com/sunbeidan/p/11905395.html
Copyright © 2020-2023  润新知