wopihost

项目介绍

基于wopi协议开发的WopiHost, 支持word, excel,ppt(仅支持预览)等文档的预览和编辑。

运行环境

需要安装Office online 2016才可以使用,基于jdk 1.8,spring boot开发。

使用案例

word文档预览

http://[owas.domain]/wv/wordviewerframe.aspx?WOPISrc=http://[WopiHost.domain]:8080/wopi/files/test.docx&access_token=123 word view

word文档编辑

http://[owas.domain]/we/wordeditorframe.aspx?WOPISrc=http://[WopiHost.domain]:8080/wopi/files/test.docx&access_token=123 word edit

excel预览

http://[owas.domain]/x/_layouts/xlviewerinternal.aspx?ui=zh-CN&rs=zh-CN&WOPISrc=http://[WopiHost.domain]:8080/wopi/files/test.xlsx&access_token=123

excel编辑

http://[owas.domain]/x/_layouts/xlviewerinternal.aspx?edit=1&WOPISrc=http://[WopiHost.domain]:8080/wopi/files/test.xlsx&access_token=123

ppt预览

http://[owas.domain]/p/PowerPointFrame.aspx?PowerPointView=ReadingView&WOPISrc=http://[WopiHost.domain]:8080/wopi/files/test.pptx&access_token=123

ppt编辑

http://[owas.domain]/p/PowerPointFrame.aspx?PowerPointView=EditView&WOPISrc=http://[WopiHost.domain]:8080/wopi/files/test.pptx&access_token=123

备注:[owas.domain]是Office online 2016的ip地址,[WopiHost.domain]是WopiHost服务的ip。 使用时替换成自己的服务地址,将test.docx换成自己对应文件路径下的文件名。

常见问题

  • word文档仅支持.docx,不支持.doc格式。
  • ppt仅支持预览,不支持编辑。
  • 如果wopihost的接口都没有问题,但是不能预览或者编辑文档,可能wopi和Office Web Apps Server之间的网络不能互通,也可能Office Web Apps Server有问题,建议重新安装后重试。
  • access_token没有做校验,需要的自己实现一下。
  • 中文名字的文档不能预览、编辑,将中文名使用URLEncoder.encode进行两次编码。例如:哈哈哈.xlsx, 使用中文编码后的名字作为参数 .../wopi/files/%25e5%2593%2588%25e5%2593%2588%25e5%2593%2588.xlsx即可正常预览。

posted on   lcs-帅  阅读(564)  评论(0编辑  收藏  举报

编辑推荐:
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

点击右上角即可分享
微信分享提示