【问题标题】:Libreoffice calc: loop throught cells macroLibreoffice calc:循环遍历单元格宏
【发布时间】:2013-10-25 04:03:33
【问题描述】:
我搜索了很多,但几乎找不到关于 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 我不知道。
谁能帮帮我。
谢谢,
布鲁诺
【问题讨论】:
标签:
macros
libreoffice
libreoffice-basic
libreoffice-calc
【解决方案1】:
我设法通过这种方式找到了答案:
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 函数)
【解决方案2】:
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