0

I am having difficulties with UNO to create Python macros for LibreOffice.

Final Objective: To go one row down to the last row of my table.

Table Example: enter image description here

Implemented Code (until now):

#!/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

I know the code is incomplete (for my final objective), but I expected, at least, the cursor would move to the last position in column.

Result (until now): Apparently none. The cursor doesn't move, and no other cell is selected to work with.

Important: I need to work with relative positions, because the table could have any size.

Request: Could you, please, point me how to move the cursor to the end of row or column (and one cell after too)?

  • 2
    The cursor moves, after [**.gotoEnd()**](http://www.openoffice.org/api/docs/common/ref/com/sun/star/table/XCellCursor.html#gotoEnd) its property [**.AbsoluteName**](http://www.openoffice.org/api/docs/common/ref/com/sun/star/sheet/SheetCellRange.html#AbsoluteName) will be `$Base_de_Dados.$AMI$1048575` (most likely, for a standard sheet size). It's just that this movement is not displayed on the sheet (and should not be displayed). To move to the end of the table, you must use [**gotoEndOfUsedArea**](http://www.openoffice.org/api/docs/common/ref/com/sun/star/sheet/XUsedAreaCursor.html) – JohnSUN Aug 03 '21 at 05:31
  • For all things libreoffice and macros see `Andrew Pitonyak` his macro bible and other resources can be found here: https://www.pitonyak.org/oo.php – Rolf of Saxony Aug 07 '21 at 06:22

0 Answers0