此外,在 OpenOffice 中制作小文档,然后检查 xml 并将其与 ODFPy 生成的 XML 进行比较,可以极大地帮助您调试可能出错的位置。
The documentation is unfortunately horrible, and the generated Python wrapper is lousily documented in code, providing lots of functions whose argument lists look like func(*args).
The reference manual is actually useful, but not when you're starting out - it doesn't provide any context of how to use these functions. I would suggest starting with the tutorial and all the examples. Even though they may have nothing to do with your use case, they will help you get the feel of how the package works. After you've gotten used to the way the package is structured, you can often make sense of the documentation by combining the API doc with the information in the OpenDocument Essentials book.
(The relationship is somewhat tenuous at best, but you can often intuit method and attribute values from it. When working with the spreadsheet, for example, the handy list of office:value-type data in the book provided the necessary constants for building proper TableCell(valuetype=...) instances)
Also, making small documents in OpenOffice and then inspecting the xml and comparing it to the XML generated from ODFPy greatly helps you debug where you might have gone wrong.
from odf.opendocument import OpenDocumentText
from odf.text import P
textdoc = OpenDocumentText()
p = P(text="Hello World!")
textdoc.text.addElement(p)
textdoc.save("helloworld", True)
Read the examples and try to make sense of everything:
发布评论
评论(6)
不幸的是,文档很糟糕,生成的 Python 包装器在代码中的记录很糟糕,提供了许多参数列表类似于 func(*args) 的函数。
参考手册实际上很有用,但在您刚开始使用时就没有用了 - 它没有提供有关如何使用这些功能的任何上下文。 我建议从 教程 和所有 示例。 尽管它们可能与您的用例没有任何关系,但它们将帮助您了解该包的工作原理。 在您习惯了包的结构方式之后,您通常可以通过将 API 文档与 OpenDocument Essentials 书。
(这种关系充其量是有点脆弱的,但您通常可以从中推断出方法和属性值。例如,在使用电子表格时,书中方便的 Office 列表:值类型数据提供了构建正确的必要常量。 TableCell(valuetype=...) 实例)
此外,在 OpenOffice 中制作小文档,然后检查 xml 并将其与 ODFPy 生成的 XML 进行比较,可以极大地帮助您调试可能出错的位置。
The documentation is unfortunately horrible, and the generated Python wrapper is lousily documented in code, providing lots of functions whose argument lists look like func(*args).
The reference manual is actually useful, but not when you're starting out - it doesn't provide any context of how to use these functions. I would suggest starting with the tutorial and all the examples. Even though they may have nothing to do with your use case, they will help you get the feel of how the package works. After you've gotten used to the way the package is structured, you can often make sense of the documentation by combining the API doc with the information in the OpenDocument Essentials book.
(The relationship is somewhat tenuous at best, but you can often intuit method and attribute values from it. When working with the spreadsheet, for example, the handy list of office:value-type data in the book provided the necessary constants for building proper TableCell(valuetype=...) instances)
Also, making small documents in OpenOffice and then inspecting the xml and comparing it to the XML generated from ODFPy greatly helps you debug where you might have gone wrong.
http://mashupguide.net/1.0/html/ch17s04.xhtml 有一个很好的 odfpy 使用示例
There's a good example of odfpy usage at http://mashupguide.net/1.0/html/ch17s04.xhtml
我在 api-for-odfpy.odt。
I found more documentation (the web site has been reorganized in the past few years) in api-for-odfpy.odt.
它有点过时了,但可以帮助某人。
我发现只有一种使用 ODFPY 的方法:
主要格式和数据位于“content.xml”和“styles.xml”中
这是一些日期时间格式示例,我有这样做:
我已经更新了代码,因为以前的版本在 MS 产品上打开错误。
It's outdated, a bit, but could help someone.
I have found only one way to work with ODFPY:
main formatting and data is located in "content.xml" and "styles.xml"
Here is some date-time format example, I have made that way:
I have updated code, a bit, because previous version opened wrong on MS product.
尝试 ezodf
他们还有一个 doc
try ezodf
they also have a doc
好的,这是一个快速帮助:
获取 odfpy 源代码:
安装它:
<前><代码> ~$ cd odfpy
~/odfpy$ python setup.py 安装
生成文档:
我已将生成的文档上传到此处。
运行这个简单的示例程序:
阅读示例并尝试理解所有内容:
希望有所帮助! 祝你好运!
Okay, here's a quick help:
Grab odfpy source code:
Install it:
Generate the documentation:
I have uploaded the generated documentation here.
Run this simple example program:
Read the examples and try to make sense of everything:
Hope that helps! Good luck!