4

我一直在搜索,但几乎找不到关于 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))

但在 libreoffice 我不知道。

谁能帮我。

谢谢,布鲁诺

4

2 回答 2

16

我设法通过这种方式找到了答案:

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

当循环结束时,我得到i与列号对应的变量。然后我可以像在 excel 中一样将它转换为字母(chr 函数)

于 2013-10-26T15:22:41.370 回答
0
rem I had a similar problem to solve.
rem Update for libreoffice 7.
rem Replaced "sheet" with "ThisComponent.Sheets(0)". 
rem Thanks.


sub main 
dim cell   as object
dim i      as integer

i = 0
rem "sheet" alone does not run
cell = ThisComponent.Sheets(0).getCellByPosition(i,0) 

while Cell.Type <> com.sun.star.table.CellContentType.EMPTY
    i    = i+1
    cell = ThisComponent.Sheets(0).getCellByPosition(i,0)   
wend
MsgBox( i )
end sub 
于 2021-02-14T23:36:25.507 回答