首页>代码>SpringBoot集成OpenOffice实现Office文档在线预览>/springboot-office/src/main/java/com/simon/springbootoffice/util/OpenOfficeUtl.java
package com.simon.springbootoffice.util; import org.jodconverter.OfficeDocumentConverter; import org.jodconverter.office.DefaultOfficeManagerBuilder; import org.jodconverter.office.OfficeException; import org.jodconverter.office.OfficeManager; import java.io.File; /** * @author Simon */ public class OpenOfficeUtl { /** * openOffice目录,window 可能在C://Program Files (x86)//OpenOffice 4 */ private static final String openOfficeHome = "C://Program Files (x86)//OpenOffice 4"; /** * openOffice端口 */ private static final int openOfficePort = 8100; /** * 转化文档 * * @param input * @param output */ public static void convert(File input, File output) throws OfficeException { try { DefaultOfficeManagerBuilder defaultOfficeManagerBuilder = new DefaultOfficeManagerBuilder(); defaultOfficeManagerBuilder.setOfficeHome(openOfficeHome); defaultOfficeManagerBuilder.setPortNumber(openOfficePort); OfficeManager officeManager = defaultOfficeManagerBuilder.build(); officeManager.start(); //转换,自动识别转化类型 OfficeDocumentConverter converter = new OfficeDocumentConverter(officeManager); converter.convert(input, output); officeManager.stop(); } catch (OfficeException e) { throw e; } } }
最近下载更多
lironggang LV38
2023年7月21日
小屁孩 LV7
2023年5月24日
ssmtest LV5
2023年3月11日
crosa_Don LV18
2023年3月2日
jk-mack LV5
2023年2月19日
doutao6677 LV25
2023年2月10日
baize12345 LV1
2023年2月1日
Possess LV4
2023年2月1日
最代码官方 LV167
2023年1月30日
最近浏览更多
DeanYao LV2
2023年10月11日
zhaixunfei LV8
2023年9月9日
cxy LV1
2023年8月23日
woldxy LV12
2023年8月22日
wang_d LV12
2023年8月15日
dfkk_love LV11
2023年7月27日
liqi666 LV7
2023年7月26日
爱吃鱼的猫Vital LV6
2023年7月24日
lironggang LV38
2023年7月21日
szf123 LV12
2023年5月31日