LibreOffice Calc的python宏中的光标不移动

2024-05-13 04:26:43 发布

您现在位置:Python中文网/ 问答频道 /正文

我在UNO为LibreOffice创建Python宏时遇到困难

最终目标: 到我桌子的最后一排

表格示例:enter image description here

实现的代码(到目前为止):

#!/bin/python3

#Script usado no programa Form_Atendimento.ods

#Cria objeto document, referenciando o documento aberto
document = XSCRIPTCONTEXT.getDocument()

#Cria objeto sheets, referenciando as planilhas
sheets = document.getSheets()

sheetForm = sheets.getByName('Form')
sheetBase = sheets.getByName('Base_de_Dados')

def testa_deslocamento(oEvent):
    
    selectedsheet = sheetBase
    cursor = selectedsheet.createCursor()
    cursor.gotoEnd()

    
    return 0

我知道代码是不完整的(对于我的最终目标),但我希望,至少光标会移动到列中的最后一个位置

结果(到目前为止): 显然没有。光标不会移动,也不会选择其他单元格进行处理

重要提示: 我需要处理相对位置,因为表可以有任何大小

请求: 您能告诉我如何将光标移到行或列的末尾(以及后面的一个单元格)吗


Tags: 代码formlibreofficedocumentcursoruno桌子光标