Libreoffice calc:循环遍历单元格宏

New*_*bie 3 macros libreoffice libreoffice-basic libreoffice-calc

我一直在搜索很多,但很难找到关于LibreOffice Basic的信息

我有点习惯在Excel中编程宏,但这次需要做一个循环,直到我到达第一个空列,它需要在libreoffice中.

在excel我会做这样的事情:

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))
Run Code Online (Sandbox Code Playgroud)

但在libreoffice我不知道.

谁能帮我.

谢谢,布鲁诺

New*_*bie 11

我设法找到答案:

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
Run Code Online (Sandbox Code Playgroud)

当循环结束时,我得到i对应于列号的变量.然后我可以将其转换为与excel(chr函数)相同的方式