【问题标题】:how to display word file and excel file using php [duplicate]如何使用php显示word文件和excel文件[重复]
【发布时间】:2019-03-27 16:17:41
【问题描述】:

我已经使用 php 上传 word 文件和 excel 文件,我想显示这些文件以查看页面。

我尝试了以下代码:

<td>
   <img style="width:12px !important; height:12px !important;"
    class="w-h-12"
    src="/manage/public/uploads/docs/2018/10/208149311.docx">
</td>

视图列表中没有显示任何内容。然后我尝试了我的框架

 <iframe src="/manage/public/uploads/docs/2018/10/208149311.docx" style="width:200px; height:200px;" frameborder="0"></iframe> 

它也不适合我

对于 jpg 图像,它工作正常

【问题讨论】:

    标签: php


    【解决方案1】:

    Google 文档查看器可以处理这个问题。

       <?php $url="/manage/public/uploads/docs/2018/10/208149311.docx";  ?>
       <iframe src="http://docs.google.com/viewer?url=<?=urlencode($url)?>&embedded=true"  style="position: absolute;width:200px; height: 200px;border: none;"></iframe>
    

    【讨论】:

    • -没有可用的预览
    • 请添加域名如 example.com/manage/public/uploads/docs/2018/10/208149311.docx"; ?>
    【解决方案2】:

    浏览器本身不支持查看 .doc 或 .docx 或 excel 文件。您必须在这样的 iframe 中使用 Google Docs Viewer

    <iframe style="width: 100%" height="500px" src="//docs.google.com/gview?url=http://www.picssel.com/demos/downloads/Fancybox.doc&embedded=true"></iframe>
    

    但请记住,它不会在 localhost 上运行,因为它会首先将文件下载到它自己的驱动器,然后它会显示该文件。

    【讨论】:

      猜你喜欢
      • 2016-06-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-17
      • 2011-07-20
      • 2020-05-30
      • 1970-01-01
      • 2013-09-03
      相关资源
      最近更新 更多