admin管理员组文章数量:1644570
最近遇到一个需求,需要在线预览office文件。查找一些资料后,发现了2个办法。
-
微软官方word 在线查看器
https://view.officeapps.live/op/view.aspx?src=自己的在线文件地址
不过这个加载文件速度有些慢。后来在github上找到了onlyoffice 这个开源项目 -
onlyoffice 项目
项目github地址https://github/ONLYOFFICE/DocumentServer
官方网站 https://api.onlyoffice/
docker 部署方法 yml文件
version: '3.7'
services:
onlyoffice:
image: onlyoffice/documentserver:5.6
ports:
- "60302:80"
volumes:
- "./onlyoffice/documentserver/logs:/var/log/onlyoffice"
- "./onlyoffice/documentserver/data:/var/www/onlyoffice/Data"
- "./onlyoffice/documentserver/sdkjs-plugins:/var/www/onlyoffice/documentserver/sdkjs-plugins"
- "./onlyoffice/documentserver/lib:/var/lib/onlyoffice/documentserver"
restart: always
记得将docker的源改为国内的网易源或者阿里源
测试地址 http://localhost:60302/welcome/
看到如下页面,表示已经安装好了
html 加载方法
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="http://localhost:60302/web-apps/apps/api/documents/api.js"></script>
<style>
html,body,#placeholder{
height: 100%;
}
</style>
</head>
<body>
<div id="placeholder" class="nav"></div>
<script language="javascript" type="text/javascript">
new DocsAPI.DocEditor("placeholder", {
"document": {
"key": null,
"title": "test6.xlsx",
// "url": "http://www.sqber/1.xlsx",
"url": "http://www.sqber/使用团队协作办公.pdf",
"fileType": "pdf",
"permissions": {
"comment": false,
"download": false,
"edit": false,
"fillForms": false,
"modifyContentControl": false,
"modifyFilter": false,
"print": false,
"review": false
},
},
"editorConfig": {
"mode": "view",
"customization": {
"chat": false,
"comments": false,
"compactHeader": true,
"compactToolbar": true,
"help": true,
}
},
"documentType": "text",// 文档类-text、表格类-spreadsheet、ppt类-presentation
"width": "100%",
"height": "100%",
// text 对应的文件类型有 .doc, .docm, .docx, .dot, .dotm, .dotx, .epub, .fodt, .htm, .html, .mht, .odt, .ott, .pdf, .rtf, .txt, .djvu, .xps
// spreadsheet 对应的文件类型有 .csv, .fods, .ods, .ots, .xls, .xlsm, .xlsx, .xlt, .xltm, .xltx
// presentation 对应的文件类型有 .fodp, .odp, .otp, .pot, .potm, .potx, .pps, .ppsm, .ppsx, .ppt, .pptm, .pptx
});
</script>
</body>
</html>
本文标签: 在线编辑ONLYOFFICEoffice
版权声明:本文标题:onlyoffice 在线预览编辑office 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/xitong/1729394420a1199704.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论