Libreoffice calc:循环遍历单元格宏

时间:2013-10-25 04:03:34

标签: 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))

但是在libreoffice我不知道。

任何人都可以帮助我。

谢谢, 布鲁诺

2 个答案:

答案 0 :(得分: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

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

相同的方式

答案 1 :(得分:0)

const date = new Date();
const month = date.toLocaleString("en-US", { month: 'short' });
const dateNum = date.getDate();
const prettyDate = `${month} ${dateNum}`;
console.log(prettyDate);