启动方法:
String OpenOffice_HOME = "C:\Program Files (x86)\OpenOffice 4\";//这里是OpenOffice的安装目录, 在我的项目中,为了便于拓展接口,没有直接写成这个样子,但是这样是绝对没问题的
// 启动OpenOffice的服务 String command = OpenOffice_HOME + "program\\soffice.exe -headless -accept=\"socket,host=127.0.0.1,port=8100;urp;\"";
Process pro = Runtime.getRuntime().exec(command);
OpenOfficeConnection connection = new SocketOpenOfficeConnection("127.0.0.1", 8100); connection.connect();//关闭服务
// close the connection connection.disconnect(); // 关闭OpenOffice服务的进程 pro.destroy();