I have slides with tables as in screenshot below. I’ve found a way to access slides, tables; but I have no idea how to access the actual content of these tables, e.g. to read/write text in cells. They don’t provide iterators, I don’t see any Rows- or Cols- providing properties… I’m completely lost here.
FTR, I have this code to access slides and tables:
#!python
import uno
# run libreoffice as:
# soffice --calc --accept="socket,host=localhost,port=2002;urp;StarOffice.ServiceManager"
def connectToLO():
# get the uno component context from the PyUNO runtime
localContext = uno.getComponentContext()
resolver = localContext.ServiceManager.createInstanceWithContext(
"com.sun.star.bridge.UnoUrlResolver", localContext )
# connect to the running office
ctx = resolver.resolve( "uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext" )
smgr = ctx.ServiceManager
desktop = smgr.createInstanceWithContext( "com.sun.star.frame.Desktop",ctx)
return desktop.CurrentComponent
model = connectToLO()
slide1 = model.DrawPages.getByIndex(0)
tables = [item for item in slide1 if item.ShapeType == 'com.sun.star.drawing.TableShape']
print(tables[0].Name)
In terminal:
$ python test.py
Table 3
How do I access cells in table now?