如何使用 python 宏获取 libreoffice 文档中段落的样式名称?
How to get the Style name of a paragraph in a libreoffice document with a python macro?
我需要为一些 odt 和 ods 文档创建一个 python 宏。
我需要找到一行的样式名称,并为我找到的每个样式做一些特定的工作。
我可以打开文档,获取行但不能获取样式。
我在网上和这里搜索过,但一无所获。
有人可以帮我写一段代码吗?
N.B。我需要一个宏,因为 odt 文件列表在 calc 工作簿中
谢谢
编辑——解决方案是
感谢 Jim K
oCursor = modelDoc.Text.createTextCursor()
oCursor.gotoStart(False)
sStyle = ''
#loop for cursor
while oCursor.gotoNextParagraph(False):
sStyle = sStyle + oCursor.getPropertyValue("ParaStyleName") + '\n'
代码给出段落中使用的所有样式的名称
阅读 ParaStyleName:
style_name = cursor.getPropertyValue("ParaStyleName")
我需要为一些 odt 和 ods 文档创建一个 python 宏。
我需要找到一行的样式名称,并为我找到的每个样式做一些特定的工作。
我可以打开文档,获取行但不能获取样式。 我在网上和这里搜索过,但一无所获。
有人可以帮我写一段代码吗?
N.B。我需要一个宏,因为 odt 文件列表在 calc 工作簿中
谢谢
编辑——解决方案是
感谢 Jim K
oCursor = modelDoc.Text.createTextCursor()
oCursor.gotoStart(False)
sStyle = ''
#loop for cursor
while oCursor.gotoNextParagraph(False):
sStyle = sStyle + oCursor.getPropertyValue("ParaStyleName") + '\n'
代码给出段落中使用的所有样式的名称
阅读 ParaStyleName:
style_name = cursor.getPropertyValue("ParaStyleName")