基于多种条件的彩色细胞我已经编写了以下代码来根据条件为单元格着色。我需要再添加一个条件 -
如果重量在Target的-2%范围内,则需要将细胞染成黄色。我该怎么做?
dt << New Column("color cells",
Formula(If(:Target> :weight, :weight << color cells("Red", Row()); .,
:weight << color cells("Green", Row()); .)),
Hide(1)
);
谢谢
Re:基于多种条件的彩色细胞1。如果您打算在JSL中工作,则需要花时间阅读“脚本指南”:帮助==>书籍==>脚本指南
2。下面是一个简单的脚本,可以按照您的描述生成着色
Names Default To Here( 1 );
dt = Current Data Table();
colNamesList = dt << get column names( string );
For( theRow = 1, theRow <= N Rows( dt ), theRow++,
For( theCol = 2, theCol <= N Items( colNamesList ), theCol++,
If(
:Target[theRow] > Column( dt, colNamesList[theCol] )[theRow],
Column( dt, colNamesList[theCol] ) << color cells( "Red", theRow );
.;,
Column( dt, colNamesList[theCol] )[theRow] < :Target[theRow] + (.02 *
Abs( :Target[theRow] )) & Column( dt, colNamesList[theCol] )[theRow] >
:Target[theRow] - (.02 * Abs( :Target[theRow] )),
Column( dt, colNamesList[theCol] ) << color cells( "Yellow", theRow );
.;,
Column( dt, colNamesList[theCol] ) << color cells( "Green", theRow );
.;
)
)
);Re:基于多种条件的彩色细胞需要编写此逻辑的变体脚本。我有4列数据,需要将每个单元格中的值与目标值进行比较。另外我不知道手中的列名。这该怎么做?简单来说,需要将A,B,C和D列中的值与Target列中的相应值和颜色代码(绿色,黄色或红色)进行相应比较。
| 目标 | 一个 | 乙 | C | d |
| 99% | 1% | 8% | 93% | 10% |
| 52% | 55% | 62% | 22% | 19% |
| 39% | 89% | 18% | 33% | 25.50% |
| 16% | 11% | 92% | 10% | 2% |
Re:基于多种条件的彩色细胞如果(
:目标>:重量,
:weight << color cells(“Red”,Row());
;,
:重量<:目标+(。02 * Abs(:目标))&:重量>:目标 - (。02 *
Abs(:目标)),
:weight << color cells(“Yellow”,Row());
;,
:weight << color cells(“Green”,Row());
。
);