有很多关于如何使用Python来控制LibreOffice文本文档和电子表格的例子,但关于如何使用绘图程序的文档很少。我想弄清楚如何在使用Python的LibreOffice中绘制流程图或至少某些形状。我使用的是Windows 10以及与LibreOffice的5来到了Python 3.3使用Python在LibreOffice中创建流程图
还有就是如何使用电子表格LibreOffice Python example
在这个例子中,如果您使用的文本文档以下行是常见的一个很好的例子,电子表格,绘图或其他文件。
import socket
import uno
localContext = uno.getComponentContext()
resolver = localContext.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", localContext)
ctx = resolver.resolve("uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext")
smgr = ctx.ServiceManager
desktop = smgr.createInstanceWithContext("com.sun.star.frame.Desktop",ctx)
model = desktop.getCurrentComponent()
下面的代码也是在修改电子表格程序的例子,它的伟大工程。该代码在电子表格中放入了“Hello World”和一个数字。
cell1 = active_sheet.getCellRangeByName("C4")
cell1.String = "Hello world"
cell2 = active_sheet.getCellRangeByName("E6")
cell2.Value = cell2.Value + 1
对于绘图程序是否有一些类似的命令来获取活动工作表并获取可以绘制的形状列表?我可能在错误的地方看,但没有找到绘图程序的任何文档。