【发布时间】:2016-09-01 03:42:45
【问题描述】:
02902982085 4 a ? <-- blue
02902982085 # 1 r <-- blue
02902982085 b $ 0 <-- blue
01395235224 w z [ <-- yellow
01395235224 a - 5 <-- yellow
10352351342 r . r <-- blue
10352351342 z 2 - <-- blue
10352351342 2 x 0 <-- blue
10352351342 q ] / <-- blue
我想根据第一列交替使用浅黄色和浅蓝色。数据按id分组,即第一列。可以有一组 10 多个或只有 1 个。如何使用本机 OpenOffice 技术来实现?
(*) 我目前的做法是使用这个 ruby 脚本来生成布尔值,我可以将其粘贴到 OpenOffice 中并执行条件格式化(参见页面底部的图片):
f = File.readlines("shading.txt") #<-- I just copy and paste a column from spreadsheet to here
$i = 0
$switch = 0
open('shading_out.txt','a'){|g|
while $i < f.size do
if f[$i] == f[$i+1]
g.puts ($switch).even?.to_s
else
if $i == (f.size-1)
$switch-=1
g.puts ($switch).even?.to_s
else
g.puts ($switch).even?.to_s
$switch+=1
end
end
$i += 1
end
}
这太荒谬了...这是上述程序的输入(实际上我只是将电子表格中的一列复制并粘贴到文本文件中):
shading.txt
02902982085
02902982085
02902982085
01395235224
01395235224
10352351342
10352351342
10352351342
10352351342
这会给出这个输出:
shading_out.txt
true
true
true
false
false
true
true
true
true
我基本上需要一种方法来获得这样的 TRUE/FALSE 列(不使用其他程序,仅使用 OpenOffice 公式/技术):
02902982085 4 a ? TRUE <-- true's would be blue with conditional formatting options (see image below)
02902982085 # 1 r TRUE
02902982085 b $ 0 TRUE
01395235224 w z [ FALSE <-- false's would be yellow, i.e., =NOT($E1) would be true for second conditional (see image below)
01395235224 a - 5 FALSE
10352351342 r . r TRUE
10352351342 z 2 - TRUE
10352351342 2 x 0 TRUE
10352351342 q ] / TRUE
这样我就可以基于“forumla is”选项执行条件格式化,在本例中为 E 列。这样所有 TRUE 条目都将是蓝色的,第二个条件将是 =NOT($E1),这将使所有FALSE 条目黄色。据我所知,OpenOffice calc 无法在 ID 切换时切换虚拟变量的值,即两个 FALSE 实例,这就是我使用 ruby 的原因...
【问题讨论】:
-
换句话说,我需要一个公式来生成这些布尔值以匹配 ID 组。
标签: ruby excel excel-formula openoffice-calc