如何阅读 Open Office 电子表格?
如何从 Groovy 读取 Open Office 3.0 电子表格 (.ods)? 我想从命名工作表中选择特定列。 理想情况下,添加“where”子句或其他条件子句会很有用。
How can I read an Open Office 3.0 spreadsheet (.ods) from Groovy? I'd like to select specific columns from a named worksheet. Ideally, it would be useful to add a 'where' clause, or other criteria clause.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我从未使用过它,但是 Open Office 有一个 Java API,当然您可以从 Groovy 使用它以及。 看起来最好的开始阅读位置是开发人员指南、Java UNO 参考 以及 < a href="http://wiki.services.openoffice.org/wiki/API/Samples/Java" rel="nofollow noreferrer">Java 和(嘿!)Groovy。 希望有帮助!
I've never used it, but Open Office has a Java API, which of course you could use from Groovy as well. It looks like the best places to start reading are the Developer's Guide, the Java UNO Reference, and the samples in Java and (hey!) Groovy. Hope that helps!
由于标题没有提及 Groovy(只有问题细节提及),我不想将其作为一个新问题。
通常如何阅读 Open Office 电子表格文档? 有一些工具可以用来创建(ooo-python),但没有用来读取的工具。 它们是 XML,但只是直率地深入研究它并试图获得提取我想要的数据的正确逻辑,这似乎不是最理想的。
我想要的是类似于 Excel COM 支持的功能,但来自命令行工具(或脚本语言)。
Since the title does not mention Groovy (only question specifics does), I didn't want to make this a new question.
How to generally read an Open Office spreadsheet document? There are tools for creating one (ooo-python) but not for reading one. They are XML but just bluntly diving into that and trying to get the right logic of extracting the data I want seems so sub-optimal.
What I'd like is features similar to Excel COM support, but from a command line tool (or scripting language).
OpenOffice 文档是 ZIP 文件,其中包含 XML 格式的文档数据以及一些其他文件(word 文档的样式表)。 可以在此处找到详细信息。
计算的主要问题是公式。 如果您只有表格数据,那么您可以简单地读取单元格值并使用它。 因此,您可以打开 ZIP 存档,读取其中的
content.xml
并使用任何 XML 解析器对其进行解析。但是当单元格包含公式时,您需要执行它。 在这种情况下,您必须通过 UNO API 打开文档。 这是 Java 版本。 您可以通过一个链接下载示例代码,该代码解释了如何打开 ODF 文档以及如何检查其内容。 还有代码片段,但没有一个显示如何检查工作表。
UNO 的主要缺点是文档。 每种方法都在某处进行了解释,但您必须首先找到解决您问题的方法。
OpenOffice documents are ZIP files which contains the document data as XML plus some other files (style sheets for word documents). Details can be found here.
The main problem with calc is formulas. If you just have tabular data, then you can simply read the cell values and use that. So you can open the ZIP archive, read the
content.xml
in it and parse that with any XML parser.But when a cell contains a formula, then you need to execute it. In this case, you will have to open the document via the UNO API. Here is the Java version. There is a link where you can download example code that explains how to open ODF documents and how to examine their content. There are also snippets but none of them show how to examine a sheet.
The main disadvantage of UNO is the documentation. Each method is explained somewhere but you have to find the method which solves your problem, first.
您可以将表/电子表格导出为 SQL 条目然后使用它吗? 您还可以查看这个 goovy 插件 - http://www.ifcx.org/< /a>
Could you export the table / spreadsheet as SQL entries then use that. You could also look at this plugin for goovy -- http://www.ifcx.org/
可能是 Spring Factories 或此处的内容Groovy 和 JMX。 有一个 Groovy 和 Open Office 的论坛。
Might be something here at Spring Factories or here at Groovy and JMX. There is a forum for Groovy and Open Office.