国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

您的位置:首頁技術文章
文章詳情頁

使用Springboot實現word在線編輯保存

瀏覽:121日期:2022-06-15 11:15:19
目錄一、查看官網二、查看下載包1、springboot 引入 pageoffice5.2.0.12.jar2、springboot 引入thymleaf3、編寫配置文件4、編寫 index.html 和 word.html4.1 index.html4.2 word.html5、編寫PageOfficeController6.application.yml 配置7.注意 項目結構三、測試輸入網址注意事項四、gitee地址總結一、查看官網

http://www.zhuozhengsoft.com/

點擊首頁下載,進入頁面:

使用Springboot實現word在線編輯保存

最新得5.2,我們就下載5.2版本進行測試。

二、查看下載包

使用Springboot實現word在線編輯保存

1.Samples5 為示例文件。放入tomcat中得webapps可以直接訪問。

localhost:8080/Samples5/index.html

2.集成文件 里面有我們需要jar包

新建springboot項目以及簡單測試這里就不多說了。

1、springboot 引入 pageoffice5.2.0.12.jar

使用Springboot實現word在線編輯保存

2、springboot 引入thymleaf

<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId></dependency>3、編寫配置文件

/** * PageOffice 配置類 */@Configurationpublic 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.html4.1 index.html

<!DOCTYPE html><html xmlns='http://www.w3.org/1999/xhtml' xmlns:th='http://www.thymeleaf.org'><head> <meta charset='UTF-8'> <title>Title</title> <!-- office插件js begin 必須引入--> <script type='text/javascript' src='https://rkxy.com.cn/jquery.min.js'></script> <script type='text/javascript' src='https://rkxy.com.cn/pageoffice.js' id='po_js_main'></script> <!-- end --></head><body><a href='javascript:POBrowser.openWindowModeless(’word’,’width=1200px;height=800px;’);'>打開文件</a></body></html>4.2 word.html

**<!DOCTYPE html><html xmlns='http://www.w3.org/1999/xhtml' xmlns:th='http://www.thymeleaf.org'><head> <meta charset='UTF-8'> <title>Title</title></head><body><input type='button' value='隱藏/顯示 標題欄' onclick='return Button1_onclick()' /><input type='button' value='隱藏/顯示 菜單欄' onclick='return Button2_onclick()' /><input type='button' value='隱藏/顯示 自定義工具欄' onclick='return Button3_onclick()' /><input type='button' value='隱藏/顯示 Office工具欄' onclick='return Button4_onclick()' /><div th:utext='${pageoffice}'> </div><script type='text/javascript'> function Save() {document.getElementById('PageOfficeCtrl1').WebSave(); } function PrintFile(){document.getElementById('PageOfficeCtrl1').ShowDialog(4); } function IsFullScreen(){document.getElementById('PageOfficeCtrl1').FullScreen = !document.getElementById('PageOfficeCtrl1').FullScreen; } function CloseFile(){window.external.close(); } function BeforeBrowserClosed(){if (document.getElementById('PageOfficeCtrl1').IsDirty){ if(confirm('提示:文檔已被修改,是否繼續關閉放棄保存 ?')) {return true; }else{return false; }} } // 隱藏/顯示 標題欄 function Button1_onclick() {var bVisible = document.getElementById('PageOfficeCtrl1').Titlebar;document.getElementById('PageOfficeCtrl1').Titlebar = !bVisible; } // 隱藏/顯示 菜單欄 function Button2_onclick() {var bVisible = document.getElementById('PageOfficeCtrl1').Menubar;document.getElementById('PageOfficeCtrl1').Menubar = !bVisible; } // 隱藏/顯示 自定義工具欄 function Button3_onclick() {var bVisible = document.getElementById('PageOfficeCtrl1').CustomToolbar;document.getElementById('PageOfficeCtrl1').CustomToolbar = !bVisible; } // 隱藏/顯示 Office工具欄 function Button4_onclick() {var bVisible = document.getElementById('PageOfficeCtrl1').OfficeToolbars;document.getElementById('PageOfficeCtrl1').OfficeToolbars = !bVisible; }</script></body></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<String,Object> map){//--- PageOffice的調用代碼 開始 -----PageOfficeCtrl poCtrl=new PageOfficeCtrl(request);poCtrl.setServerPage('/poserver.zz');//設置授權程序servletpoCtrl.addCustomToolButton('保存','Save()',1); //添加自定義按鈕poCtrl.addCustomToolButton('打印', 'PrintFile()', 6);poCtrl.addCustomToolButton('全屏/還原', 'IsFullScreen()', 4);poCtrl.addCustomToolButton('關閉', 'CloseFile()', 21);poCtrl.setSaveFilePage('/page/save');//設置保存的actionpoCtrl.webOpen('D:pagetest.docx', OpenModeType.docAdmin,'張三');poCtrl.setCaption('信息平臺');map.put('pageoffice',poCtrl.getHtmlCode('PageOfficeCtrl1'));//--- PageOffice的調用代碼 結束 -----ModelAndView mv = 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: 8080spring: 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.注意 項目結構

使用Springboot實現word在線編輯保存

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

三、測試輸入網址

http://localhost:8080/page/index

使用Springboot實現word在線編輯保存

打開文件,或讓你先進行下載pageoffice。

注意事項

1.關閉瀏覽器進行安裝

2.二要進行企業注冊,隨便填填

3.test.docx得文件需要填寫些數據。空文檔打不開!

四、gitee地址

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

總結

本篇文章就到這里了,希望能給你帶來幫助,也希望您能夠多多關注好吧啦網的更多內容!

標簽: word
相關文章:
主站蜘蛛池模板: 4455四色永久免费 | 欧美成人影院 在线播放 | 国产成人综合亚洲亚洲欧美 | 日本老熟妇激情毛片 | 求欧美精品网址 | 亚洲国产欧美视频 | 欧美日韩精品一区二区另类 | 一级做a爱过程免费视 | 18视频在线观看 | 99国产精品高清一区二区二区 | 国产精品亚欧美一区二区三区 | 男人天堂日韩 | 国产欧美成人 | 国产成人在线视频观看 | 性亚洲精品 | 草久视频在线 | 中文字幕在线看视频一区二区三区 | 国产自愉自愉全免费高清 | 91精品久久一区二区三区 | 久草三级 | 暴操女人 | aaaaaa级特色特黄的毛片 | 在线观看中文字幕一区 | 国产一区二区三区在线免费观看 | 久草视频手机在线观看 | 国产欧美日韩视频免费61794 | 久久精品国产91久久综合麻豆自制 | 日本欧美不卡一区二区三区在线 | 国产精品久久久久久久久岛 | 麻豆一级片 | 欧美一区不卡二区不卡三区 | 日韩a级一片 | 久久精品国产精品亚洲毛片 | 国内成人精品亚洲日本语音 | 欧美三级网站 | 农村寡妇特一级毛片 | 99久久综合国产精品免费 | 美女张开大腿让男人桶 | 黄色三级毛片 | 国产美女又黄又爽又色视频免费 | 欧美在线视频一区二区 |