基于Office Web Apps Server 2013 的文档在线预览汇总

时间:2022-03-23 13:01:13

1、部署Office Web AppsServer 2013后就直接提供了该功能。

下面是在本地服务器上的效果(http://aqqz-dellr710.aqqz.net/op/generate.aspx

基于Office Web Apps Server 2013 的文档在线预览汇总

用生成的url(http://aqqz-dellr710.aqqz.net/op/view.aspx?src=www.quanxuetong.com%2Fuploadfile%2F2015%2F0403%2F20150403113132101.ppt)打开后如下:

基于Office Web Apps Server 2013 的文档在线预览汇总


2、不想部署Office Web AppsServer的话,微软在自己的站点上也直接提供了该功能。

https://products.office.com/en-us/office-online/view-office-documents-online

基于Office Web Apps Server 2013 的文档在线预览汇总

打开生成的url(https://view.officeapps.live.com/op/view.aspx?src=www.quanxuetong.com%2Fuploadfile%2F2015%2F0403%2F20150403113132101.ppt)后如下:

基于Office Web Apps Server 2013 的文档在线预览汇总

界面上与本地的有一点不同。发现网易126邮箱附件预览也采用了类似的方法,用iframe嵌入的,对比一下:

基于Office Web Apps Server 2013 的文档在线预览汇总

几乎是一样的,url上多了些参数。


3、国内一家http://www.officeweb365.com站点提供了预览服务。

链接及参数说明:
http://officeweb365.com/o/?i=您的网站ID&furl=文件下载地址
例:http://officeweb365.com/o/?i=1&furl=http://a.com/downfile/a.doc

下图是利用iFrame嵌套的结果

基于Office Web Apps Server 2013 的文档在线预览汇总

实际地址是:http://officeweb365.com/o?i=34&furl=http%253A%252F%252Fofficeweb365.com%252Fviewfile%252Fnet%252F20150403113132101.ppt

更多关于Office Web Apps Server看这里:https://technet.microsoft.com/zh-cn/library/jj219458.aspx

 

以上三种方法好处是没什么难度,基本不需要开发,缺点也很明显,给处了文档的真实地址,(www.quanxuetong.com/uploadfile/2015/0403/20150403113132101.ppt)文档可以直接下载了。

 

4、自己做Wopi Host(Server端)

基于Office Web Apps Server 2013 的文档在线预览汇总

最终还是通过Office Web Apps Server实现的,不过将Office Web Apps Server作为WOPI的Client,存放文档的是WOPI的Server(Host),通过动态的token访问。

也就两个API:

GETapi/wopi/files/{name}?access_token={access_token}

GETapi/wopi/files/{name}/contents?access_token={access_token}

具体看这:https://code.msdn.microsoft.com/Building-an-Office-Web-f98650d6

代码更新到:UPDATE: 2014-January-31

部署后如下图:

基于Office Web Apps Server 2013 的文档在线预览汇总

以上要部署到IIS中,VS自带的不行,还要注意防火墙设置。

在线的DEMO:http://www.fzzsh.cn/WopiEdit/


国内博客文章:

如何整合Office Web Apps至自己开发的系统(一)http://www.cnblogs.com/poissonnotes/p/3267190.html

如何整合Office Web Apps至自己开发的系统(二)http://www.cnblogs.com/poissonnotes/p/3277280.html

 

 

另外:通过:KB2760445补丁也支持PDF,这样就比较全面了。

Office Web Apps Server 2013与PDF(一)http://www.cnblogs.com/erucy/archive/2013/07/05/3173707.html

Office Web Apps Server 2013与PDF(二)http://www.cnblogs.com/erucy/p/3195513.html

 

===========================================================

现在两个问题:

1、不用 c# 写HOST

2、在线编辑的实现(据说:难点在doc上,因为doc是自动保存的,其他xls、ppt等是一次性保存的。参考下面的)

http://*.com/questions/17065029/can-i-just-use-office-web-apps-server

You can write your own server that implements WOPI protocol, this will support PPTX/XSLX in view/edit mode, DOCX/PDF in view mode only. WOPI server is pretty simple to implement.

To edit word docs you need to implement Cobalt or FSSHTTP/FSSHTTPB protocol.

...

the final update - the complete solution is here:

https://github.com/thebitllc/WopiBasicEditor