Libre Office Calc复制并将值加倍到其他列

时间:2017-08-17 14:53:25

标签: libreoffice-calc

我在Libreoffice Calc A栏中有例如

1
5
25
7

我希望使用一些复制方法创建B列

1
1
5
5
25
25
7
7

它必须是一些简单的解决方案,但我找不到它:(

感谢您的回答

回答这个问题是针对Excel,但我需要LibreOffice Calc(我的错,我之前要求excel)

3 个答案:

答案 0 :(得分:3)

在B1:

=INDEX(A:A,INT((ROW(1:1)-1)/2)+1)

复制/向下拖动

/2更改为您想要重复的时间。

+1更改为您的数据在该列中开始的行号。

enter image description here

答案 1 :(得分:2)

为了适应Scott Craner对LO Calc的回答,B1中的公式应为:

=INDEX(A:A,INT((ROW()-1)/2)+1)

或者这个:

=INDIRECT(ADDRESS(INT((ROW()-1)/2)+1,1))

spreadsheet result

文档:INDEXINDIRECTADDRESSROW

答案 2 :(得分:1)

我独自找到了解决方案,但斯科特帮助我太多了......谢谢

 String enter = "2017-08-16 05:00:00";
    String out = "2017-08-17 15:00:00";
    DateTimeFormatter time_format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); //need to format date fore recognition
    LocalDateTime start = LocalDateTime.parse(enter,time_format);
    LocalDateTime finish = LocalDateTime.parse(out,time_format);
    Duration duration = Duration.between(start,finish); // duration between 2 dates

    int duringDay = 0; // storing hours during day
    int duringNight = 0; // storing hours during night

    for (int i=1;i<=duration.toHours();i++){ // from 1 to number of hours between 2 dates

    LocalDateTime ldt = start.plusHours(i); // for every hour in a range give +1 form started time 5am in this example

    if(ldt.getHour()<=6 || ldt.getHour()>21){ // while it's adding check if hour is between 6am and 21

        duringNight++; // if it's not add to duringNight integer

    } else {duringDay++;} // else give it to duringDay integer

    }

    System.out.println("Day:" + duringDay + "\n" + "Night:" + duringNight);