Springboot整合PageOffice 实现word在线编辑保存功能

网友投稿 692 2022-12-20

Springboot整合PageOffice 实现word在线编辑保存功能

Springboot整合PageOffice 实现word在线编辑保存功能

目录一、查看官网二、查看-包三、测试 四、gitee地址

一、查看官网

http://zhuozhengsoft.com/

Iqtxt

点击首页-,进入页面:

最新得5.2,我们就-5.2版本进行测试。

二、查看-包

Samples5 为示例文件。放入tomcat中得webapps可以直接访问。

localhost:8080/Samples5/index.html集成文件 里面有我们需要jar包

新建springboot项目以及简单测试这里就不多说了。

1、springboot 引入 pageoffice5.2.0.12.jar

2、springboot 引入thymleaf

org.springframework.boot

spring-boot-starter-thymeleaf

3、编写配置文件

/**

* PageOffice 配置类

*/

@Configuration

public class PageOfficeConfig {

@Value("${file.save.path}")

String poSysPath;

/**

* 添加PageOffice的服务器端授权程序Servlet(必须)

* @return

*/

@Bean

public ServletRegistrationBean servletRegistrationBean() {

com.zhuozhengsoft.pageoffice.poserver.Server poserver = new com.zhuozhengsoft.pageoffice.poserver.Server();

//设置PageOffice注册成功后,license.lic文件存放的目录

poserver.setSysPath(poSysPath);

ServletRegistrationBean srb = new ServletRegistrationBean(poserver);

srb.addUrlMappings("/poserver.zz");

srb.addUrlMappings("/posetup.exe");

srb.addUrlMappings("/pageoffice.js");

srb.addUrlMappings("/jquery.min.js");

srb.addUrlMappings("/pobstyle.css");

srb.addUrlMappings("/sealsetup.exe");

return srb;

}

}

4、编写 index.html 和 word.html

4.1 index.html

打开文件

4.2 word.html

**

**

5、编写PageOfficeController

/**

* PageOffice Demo

*/

@Controller

@RequestMapping("/page")

public class PageOfficeController {

/**

* 进入测试

* @return

*/

@RequestMapping(value="/index", method=RequestMethod.GET)

public ModelAndView showIndex(){

ModelAndView mv = new ModelAndView("index");

return mv;

}

/**

* office online打开

* @param request

* @param map

* @return

*/

@RequestMapping(value="/word", method=RequestMethod.GET)

public ModelAndView showWord(HttpServletRequest request, Map map){

//--- PageOffice的调用代码 开始 -----

PageOfficeCtrl poCtrl=new PageOfficeCtrl(request);

poCtrl.setServerPage("/poserver.zz");//设置授权程序servlet

poCtrl.addCustomToolButton("保存","Save()",1); //添加自定义按钮

poCtrl.addCustomToolButton("打印", "PrintFile()", 6);

poCtrl.addCustomToolButton("全屏/还原", "IsFullScreen()", 4);

poCtrl.addCustomToolButton("关闭", "CloseFile()", 21);

poCtrl.setSaveFilePage("/page/save");//设置保存的action

poCtrl.webOpen("D:\\page\\test.docx", OpenModeType.docAdmin,"张三");

poCtrl.setCaption("信息平台");

map.put("pageoffice",poCtrl.getHtmlCode("PageOfficeCtrl1"));

//--- PageOffice的调用代码 结束 -----

ModelAndView mhttp://v = new ModelAndView("word");

return mv;

}

/**

* 保存

* @param request

* @param response

*/

@RequestMapping("/save")

public void saveFile(HttpServletRequest request, HttpServletResponse response){

FileSaver fs = new FileSaver(request, response);

fs.saveToFile("d:\\page\\" + fs.getFileName());

fs.close();

}

}

6.application.yml 配置

server:

port: 8080

spring:

datasource:

driver-class-name: com.mysql.cj.jdbc.Driver

url: jdbc:mysql://localhost:3306/test?useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=UTC

username: root

password: finn123

# thymeleaf页面模板配置

thymeleaf:

prefix: classpath:/templates/

suffix: .html

mvc:

view:

prefix: classpath:/templates/

suffix: .html

resources:

static-locations: classpath:/templates/,classpath:/static/

file:

save:

path: d:/page/

7.注意

项目结构

注意jquery.min.js 和 pageoffice.js文件地址

三、测试

输入网址

http://localhost:8080/page/index

打开文件,或让你先进行-pageoffice。

注意事项

关闭浏览器进行安装

二要进行企业注册,随便填填

test.docx得文件需要填写些数据。空文档打不开!

四、gitee地址

https://gitee.com/finn_feng/finnPageOffice.git

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:一篇文章带你了解XGBoost算法
下一篇:springboot如何使用@ConfigurationProperties封装配置文件
相关文章

 发表评论

暂时没有评论,来抢沙发吧~