2

我制作了一个 RDLC 报告,它从我提供的数据集生成它的 tablix。我需要单元格的内容(Tablix 中的每个文本框)根据其内容更改其背景颜色。

例如:

Name | Val  
Joe  | 80  
Lee  | 60  
Fred | 30  
Bill | 57  

我的条件是小于 60 应将其背景色更改为红色。(因此,30 和 57 的背景色将变为红色)。

注意:由于它是从数据集加载的,因此您不能直接设置它。如果我们将条件作为参数传递给 rdlc 并自行工作,有什么办法吗?

4

1 回答 1

5

在背景属性中使用表达式。您可以使用: 获取您已读取的某些字段的当前值Fields.Name_Of_Field.Value,它将自动移动到每一行的正确值。

如果您有单个测试,您可以使用它

=IIF(Fields.Val.Value < 60, "Red", "Blue")

如果您有多个测试,您可以使用它

=SWITCH(
 Fields.Val.Value < 60, "Red",
 Fields.Val.Value < 80 && Fields.Val.Value >= 60, "Blue",
         .
         . add other tests here
         .
 "Black") ' default is black in case all the tests fail

One of the great things about RDL is the number places you can use expressions. Try this for a starter

于 2012-10-14T01:42:42.300 回答