如何在LibreOffice中使用自定义间隔创建(编号)系列

问题描述 投票:1回答:1

想象一下,你有下表,见下面。现在,我想告诉LibreOffice在所有三个列中创建一个系列,每个列都有自定义的时间间隔。这可能吗?

该系列应如下:

  1. 每112行增加1并在其间插入当前数字。
  2. 每28行增加1并在其间插入当前数字。
  3. 每7行增加1并在其间插入当前数字。

time-series libreoffice-calc
1个回答
0
投票

您可以使用公式=INT((ROW()-1)/period)+startingNumber并将其向下拖动(在所选单元格的右下角使用黑色方块)将其复制到行数。

或者你可以使用简单的宏(其中period等于7,28或112):

Option Explicit

Sub Main

    Dim numberOfRows, n, period, startingNumber As Integer
    Dim destinationCell As Variant

    period = 7
    numberOfRows = 30
    startingNumber = 1
    For n = 0 To numberOfRows-1
        destinationCell=ThisComponent.Sheets.getByIndex(0).getCellByPosition(0,n)
        destinationCell.setValue(Int(n/period)+startingNumber)
    Next n

End Sub
© www.soinside.com 2019 - 2024. All rights reserved.