解决方案是使用控制器的方法 .getTrasferable() 从 ViewCursor 获取数据。这反过来要求您控制视图光标并将其定位在每个单元格中(我无法使 ViewCursor 跨越多个单元格)。一旦你获得了可转移的,你将光标放在目的地并插入。
desktop = context.ServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop", context)
document = desktop.loadComponentFromURL("file://%s/template-debug.odt" % os.getcwd() ,"_blank", 0, ())
controller=document.getCurrentController()
table = document.TextTables.getByIndex(0)
view_cursor=controller.getViewCursor()
src = table.getCellByName(src_name)
dst = table.getCellByName(dst_name)
view_cursor.gotoRange(src.Text, False)
txt = controller.getTransferable()
view_cursor.gotoRange(dst.Text, False)
controller.insertTransferable(txt)