Java + OpenOffice,互操作自动化真的这么难吗?
我正在尝试用 Java 重写我的 C# 应用程序。我选择 Java 是因为我们的目标平台现在是 Linux,不再是 Windows。
我的 C# 应用程序使用 Microsoft Office Interop 来自动化 Word 和 Excel 等内容。它只会打开不同的文档并对它们应用我们的格式(调整列宽、删除斜体等)。最后,它会将文档另存为 PDF。
既然我们的目标是 Java 和 Linux,并且知道 OpenOffice 可以完成所有这些事情,我认为这将是一个平稳的过渡。 OpenOffice是开源的,那么它一定有一个比较漂亮的自动化界面吧?
我整个上午都在谷歌搜索和查看文档。我已经下载了 OpenOffice SDK。我已按照涉及安装 MinGW 和 Zip 工具包的说明进行操作。我尝试过 NetBeans 插件和 Eclipse 配置设置。
有趣的是,我什至不确定我的方向是否正确。我一直在阅读有关 OpenOffice UDO 界面的内容,但这听起来更像是 OpenOffice 脚本,例如 VBA 之类的。
有谁知道是否有某种导入可以让我使用 OpenOffice 打开和操作文档,类似于 Office 的互操作库?如果是这样,知道最近有什么例子或博客文章等吗?
I'm trying to re-write a C# application of mine in Java. I've chosen Java because our target platform is now Linux, no longer Windows.
My C# application used Microsoft Office Interop to automate things like Word and Excel. It would simply open different documents and apply our formatting to them (adjust column width, remove italics, etc). Finally, it would save the documents as PDF.
Now that we are targeting Java and Linux, and knowing that OpenOffice can do all of these things, I figured it would be a smooth transition. OpenOffice is open source, so it must have a relatively nice automation interface, right?
I've been Google'ing and looking at docs all morning. I've downloaded the OpenOffice SDK. I've followed instructions involving installing MinGW and a Zip toolkit. I've tried NetBeans plugins and Eclipse configuration settings.
The funny thing is, I'm not even sure if I'm in the right direction. I've been reading about OpenOffice UDO interface, but that sounds more like in-OpenOffice Scripts, like VBA or something.
Does anyone know if there's simply some sort of import that allows me to use OpenOffice to open and manipulate documents, similar to Office's Interop libraries? If so, know of any recent examples or blog posts, etc?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,OpenOffice jar 文件本身(来自应用程序)就是 SDK。接口涉及调用其中的方法。一旦你弄清楚了,这并不难,但我同意,它的文档相当薄弱。它肯定是由知道如何做的人编写的,并且可以将其用作参考,但不擅长向其他人解释它。 :-)
Yes, the OpenOffice jar files themselves (from the app) are the SDK. The interface involves calling methods in them. It's not hard once you figure it out, but I agree, documentation for it is pretty weak. It was definitely written by people that know how to do it, and can use it as a reference, but aren't any good at explaining it to others. :-)