在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
office介绍(新版本现已支持microsoft office和wps的在线编辑,https://gitee.com/saver-live/editoffice)1 准备工作1.1 操作系统服务器可以为linux和windows皆可,用户端电脑需为window用户,且需安装easy-office插件和office2013以上.下载链接: https://pan.baidu.com/s/1D8wusnMURFICpfhk5eJz4A 密码: l49e1.2 导入依赖添加easy-office.jar到项目 1.3 java(Springboot)集成 @Configurationpublic class ServletConfig { @Autowired private ServerConfig serverConfig; @Bean public ServletRegistrationBean office() { OfficeServlet officeServlet = new OfficeServlet(); ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean( officeServlet, "/office/*"); servletRegistrationBean.addInitParameter("rootPath", serverConfig.getUploadPath()); return servletRegistrationBean; } } 1.4请求office在线编辑 private R openAppendix(SysAppendixEntity sysAppendixEntity, Boolean readOnly) { try { OfficeRegister officeRegister = OfficeRegister.getInstance(); officeRegister.setKey("key"); officeRegister.setRequestUrl(HttpContextUtils.getDomain() + "/office/"); String absolutePath = getFile(sysAppendixEntity).getAbsolutePath(); String replace = absolutePath.replace(serverConfig.getUploadPath(), "").replace("\\", "/"); String register = officeRegister.register("/" + replace, readOnly); return R.ok().put("data", register); } catch (Exception e) { e.printStackTrace(); return R.error(); } } 1.5web js执行返回字符串window.location.href = res.data1.6 用户安装插件
|
请发表评论