其实网上已经有不少关于.Openoffice使用的文章的.我这里只不过是画蛇添足多此一举.但是.因为长期不添足.现在说都不会话了.还是写点吧.希望对你有帮助.我最讨厌废话连篇了.所以不说废话了.还有我的表达能力有限.希望大家能凑合看.不要有不清楚的地方.可以留言讨论.也可以给我发邮件..(本人邮箱垃圾邮件堆满了,不一定能看到.)现在开始讲了.还有,没有用中文标点.这属于个人习惯吧.算了废话又来了开始讲了哦.
首先需要安装Openoffice主程序.
去Openoffice主站下载.
然后安装Openofficejdk.
从jdk的example文件夹中找到了学习步骤...就按照他的走吧
下载是摘自他的源码
/*************************************************************************
*
* The Contents of this file are made available subject to the terms of
* the BSD license.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Sun Microsystems, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*************************************************************************/
public class FirstUnoContact {
public static void main(String[] args) {
try {
// get the remote office component context
com.sun.star.uno.XComponentContext xContext =
com.sun.star.comp.helper.Bootstrap.bootstrap();
System.out.println("Connected to a running office ...");
com.sun.star.lang.XMultiComponentFactory xMCF =
xContext.getServiceManager();
String available = (xMCF != null ? "available" : "not available");
System.out.println( "remote ServiceManager is " + available );
}
catch (java.lang.Exception e){
e.printStackTrace();
}
finally {
System.exit(0);
}
}
}
你运行吧肯定报错..绝对报错.
因为他的默认路径是找不到的..估计环境变量中得设置..
于是参考了一个哥们的笔记
http://www.xue5.com/Office/OpenOffice/441298_4.html
下载了个bootstrapconnector.jar
代码修改成如下:
package ansj.sun.os;
import ooo.connector.BootstrapSocketConnector;
import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.uno.XComponentContext;
public class ConnOpenOffice {
public static void main(String[] args) {
try {
// 连接OpenOffice
String oooExecFolder = "C:/Program Files/OpenOffice.org 3/program/" ;
XComponentContext xContext = BootstrapSocketConnector.bootstrap(oooExecFolder) ;
System.out.println("Connected to a running office ...");
XMultiComponentFactory xMCF = xContext.getServiceManager();
String available = (xMCF != null ? "available" : "not available");
System.out.println( "remote ServiceManager is " + available );
}
catch (java.lang.Exception e){
e.printStackTrace();
}
finally {
System.exit(0);
}
}
}
运行..发生错误如下...
com.sun.star.comp.helper.BootstrapException
at ooo.connector.BootstrapConnector.connect(BootstrapConnector.java:129)
at ooo.connector.BootstrapSocketConnector.connect(BootstrapSocketConnector.java:68)
at ooo.connector.BootstrapSocketConnector.connect(BootstrapSocketConnector.java:45)
at ooo.connector.BootstrapSocketConnector.bootstrap(BootstrapSocketConnector.java:82)
at ansj.sun.os.ConnOpenOffice.main(ConnOpenOffice.java:13)
于是你打开任务管理器看看是否有
office.bin 和 office.exe 这两个进程,如果没有那就是因为Openoffice的服务没有启动.
你需要cmd到Openoffice主程序的安装目录下
cd C:\Program Files\OpenOffice.org 3\program
运行如下命令
soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard
如果没有保存哦.你再看任务管理器的进程是不是多出了office.bin 和 office.exe
现在重新运行程序
Connected to a running office ...
remote ServiceManager is available
出现如下..呵呵成功了...
分享到:
相关推荐
本文整理自互联网,非本人创作,只为分享。
NULL 博文链接:https://steal.iteye.com/blog/2033646
OpenOffice_4.1.6_Linux和OpenOffice_4.1.7_Linux两个安装包和安装文档, 已经经历过亲测安装使用
openoffice
Apache OpenOffice API 是用于访问 Apache OpenOffice 的通用编程接口。可以使用 Apache OpenOffice API 创建、打开、修改和打印 Apache OpenOffice 文档。它提供了通过个人宏扩展 Apache OpenOffice 功能范围的选项...
不用理会后面的版本号,我是为了和maven中心仓库区分所以才用1.11的,说明:中心仓库的不可用,openoffice可能用到的一个jar包 jacob.jar
openoffice cmd启动命令 通过cmd来启动openoffic服务
openoffice编译需要的一个txt文件,在进行/bootstrap时,需要对整个编译环境进行检查和下载文件。参考本人上传的其他一个文件。
RHEL下怎样手动安装openoffice
所以这里找到了一个替换的服务,就是libreoffice,支持arm64架构。 这里提供相关的文件,启动方式和openoffice是一样的,解压即可使用。 这里提供相关的docker制作文档说明,可以参考这里:...
Apache OpenOffice是一款先进的开源 办公软件套件,它包含文本文档、电子表格、演示文稿、绘图、数据库等。 它能够支持许多语言并且在所有普通计算机上工作。它将你所有的数据以国际开放标准格式存储下来,并能够...
openmeeting openoffice启动8100端口文件
封装了my sql,sql server,oracle等多种数据库的连接池,里面有使用的例子,配置文件在db.properties,是一个Eclipse的项目源码。
基于OpenOffice的协同编辑系统zOffice的研究.pdf
一份非常实用的openoffice中文版开发文档,实用于对openoffice的web开发项目
Apache OpenOffice 是一款办公软件,引导文字处理、电子表格、幻灯片演示、图形处理、数据库工具以及支持更多功能的开源的 Office 办公套件。该软件支持多国语言并且可以在所有普通PC电脑上正常工作。Apache ...
导入这些包,安装好openoffice,实现openoffice文档转换在线预览参考博客:http://blog.csdn.net/tan313/article/details/47952055
openoffice示例.rar
c#使用openoffice组件操作文件,各主流文件之间的转换,word,html,excel,pdf等等
想要linux平台下openoffice软件可以留言