Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Libreoffice calc: loop throught cells macro

I've been searching a lot but could find little to no info about LibreOffice Basic

I'm a bit used to programming macros in excel but this time a need to do a loop until i reach the first empty column and it needs to be in libreoffice.

In excel i would do something like this:

Dim i As integer

i = 0
Range("A1").Select
While cell.Offset(0, i).Value <> Null
    i = i + 1
Wend
MsgBox ("First empty column is " & Chr(i + 64))

But in libreoffice i have no idea.

Can anyone help me.

Thanks, Bruno

like image 251
Newbie Avatar asked Dec 05 '22 08:12

Newbie


1 Answers

I managed to find the answer this way:

dim cell as object
dim i as integer

i = 0
cell = Sheet.getCellByPosition(i,0)

while Cell.Type <> com.sun.star.table.CellContentType.EMPTY
    i = i+1
    cell = Sheet.getCellByPosition(i,0)
wend

When the loop ends I get the variable i which corresponds to the column number. I can then convert it to the letter the same way as in excel (chr functions)

like image 179
Newbie Avatar answered Dec 27 '22 10:12

Newbie