0
我想实现类似于Excel的即渐变色基础上的最低值(红色)到最高值(绿色)的“色阶”功能简化的结果,除了在我的交叉表使用Crystal Reports 2008我的交叉表看起来有点像这样:水晶报表交叉表条件格式
HOURS L1 L2 L3 L4 Total
1 hours | 5 | 0 | 1 | 16 | 22 |
2 hours | 0 | 1 | 0 | 10 | 11 |
3 hours | 8 | 2 | 6 | 12 | 28 |
TOTAL |13 | 3 | 7 | 38 | 61 |
我的函数的原理是找到在交叉表中的最大值,然后用20%,40%,60%,80个%值着色背景。功能如下(格式>背景部分):
if currentfieldvalue < ((Maximum (MakeArray (CurrentColumnIndex, CurrentRowIndex, 1)))*0.2) then color(255,0,0)
else if (currentfieldvalue >= ((Maximum (MakeArray (CurrentColumnIndex, CurrentRowIndex, 1)))*0.2) and
currentfieldvalue < ((Maximum (MakeArray (CurrentColumnIndex, CurrentRowIndex, 1)))*0.4)) then color(255,192,0)
else if (currentfieldvalue >= ((Maximum (MakeArray (CurrentColumnIndex, CurrentRowIndex, 1)))*0.4) and
currentfieldvalue < ((Maximum (MakeArray (CurrentColumnIndex, CurrentRowIndex, 1)))*0.6)) then color(255,255,0)
else if (currentfieldvalue >= ((Maximum (MakeArray (CurrentColumnIndex, CurrentRowIndex, 1)))*0.6) and
currentfieldvalue < ((Maximum (MakeArray (CurrentColumnIndex, CurrentRowIndex, 1)))*0.8)) then color(146,208,80)
else if (currentfieldvalue >= ((Maximum (MakeArray (CurrentColumnIndex, CurrentRowIndex, 1)))*0.8)) then color(0,176,80)
这不是优雅,也不正常工作,任何帮助/建议将不胜感激。我没想到它是如此的复杂,因为最初我是用下面的假设它会工作,但它告诉我,“CurrentFieldValue”不是一个领域的工作。
if CurrentFieldValue < ((Maximum (CurrentFieldValue))*0.2) then color(255,0,0)
else if ... etc.