LibreOffice 邮件合并 Java
LibreOffice Mail Merge with Java
我正在尝试从 java 应用程序自动使用 libre office 邮件合并功能。
我尝试安装 libreoffice sdk 但没有成功,因为它们需要不再可用的软件(例如 zip-tools)。无论如何,我能够获得 jar 文件(jurtl-3.2.1.jar、ridl-3.2.1.jar、unoil-3.2.1.jar 和 juh-3.2.1.jar)来自 Maven 存储库。
有了这个 jar 文件,我能够重现此处提供的许多示例 http://api.libreoffice.org/examples/examples.html#Java_examples
同样在 LibreOffice API 文档中列出了名为 'MailMerge' 的服务(参见此处 http://api.libreoffice.org/docs/idl/ref/servicecom_1_1sun_1_1star_1_1text_1_1MailMerge.html)
但是在 none 的 jar 中这个服务 class 是可用的,我唯一可用的实例是 MailMergeType。
我可以在我的 java 代码中打开一个 *.odt 模板文件,下一步是创建一个邮件合并服务实例并将一个 *.csv 数据源文件传递给邮件合并服务。
在 API 文档中列出了一些可以帮助我的功能,但正如我之前所说,我无法访问此服务 class 因为它根本不存在于所提供的jar 文件。
有人知道我如何才能访问 libreoffice 的邮件合并服务吗?
如果您需要有关我的环境的更多信息,请询问。
此致
看看 this code from 2004,显然你可以简单地使用 Java 的 Object
class。以下是该代码的一些片段:
Object mmservice = null;
try {
// Create an instance of the MailMerge service
mmservice = mxMCF.createInstanceWithContext(
"com.sun.star.text.MailMerge", mxComponentContext);
}
// Get the XPropertySet interface of the mmservice object
XPropertySet oObjProps = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class, mmservice);
try {
// Set up the properties for the MailMerge command
oObjProps.setPropertyValue("DataSourceName", mDataSourceName);
}
// Get XJob interface from MailMerge service and call execute on it
XJob job = (XJob) UnoRuntime.queryInterface(XJob.class, mmservice);
try {
job.execute(new NamedValue[0]);
}
另见 How to do a simple mail merge in OpenOffice。
关于旧 zip 工具的来源,请尝试 http://www.willus.com/archive/zip64/ 中的 zip.exe
。
我正在尝试从 java 应用程序自动使用 libre office 邮件合并功能。
我尝试安装 libreoffice sdk 但没有成功,因为它们需要不再可用的软件(例如 zip-tools)。无论如何,我能够获得 jar 文件(jurtl-3.2.1.jar、ridl-3.2.1.jar、unoil-3.2.1.jar 和 juh-3.2.1.jar)来自 Maven 存储库。
有了这个 jar 文件,我能够重现此处提供的许多示例 http://api.libreoffice.org/examples/examples.html#Java_examples
同样在 LibreOffice API 文档中列出了名为 'MailMerge' 的服务(参见此处 http://api.libreoffice.org/docs/idl/ref/servicecom_1_1sun_1_1star_1_1text_1_1MailMerge.html)
但是在 none 的 jar 中这个服务 class 是可用的,我唯一可用的实例是 MailMergeType。
我可以在我的 java 代码中打开一个 *.odt 模板文件,下一步是创建一个邮件合并服务实例并将一个 *.csv 数据源文件传递给邮件合并服务。
在 API 文档中列出了一些可以帮助我的功能,但正如我之前所说,我无法访问此服务 class 因为它根本不存在于所提供的jar 文件。
有人知道我如何才能访问 libreoffice 的邮件合并服务吗?
如果您需要有关我的环境的更多信息,请询问。
此致
看看 this code from 2004,显然你可以简单地使用 Java 的 Object
class。以下是该代码的一些片段:
Object mmservice = null;
try {
// Create an instance of the MailMerge service
mmservice = mxMCF.createInstanceWithContext(
"com.sun.star.text.MailMerge", mxComponentContext);
}
// Get the XPropertySet interface of the mmservice object
XPropertySet oObjProps = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class, mmservice);
try {
// Set up the properties for the MailMerge command
oObjProps.setPropertyValue("DataSourceName", mDataSourceName);
}
// Get XJob interface from MailMerge service and call execute on it
XJob job = (XJob) UnoRuntime.queryInterface(XJob.class, mmservice);
try {
job.execute(new NamedValue[0]);
}
另见 How to do a simple mail merge in OpenOffice。
关于旧 zip 工具的来源,请尝试 http://www.willus.com/archive/zip64/ 中的 zip.exe
。