SSRS:每组有不同的颜色?

时间:2015-07-18 22:45:22

标签: reporting-services reporting business-intelligence ssrs-2008-r2 ssrs-2012

如何使用不同的背景颜色格式化SQL Server Reporting Services(SSRS)中的每个组以及具有相同颜色的组的项目?如下图所示:

任何提示或想法?

提前致谢

enter image description here

1 个答案:

答案 0 :(得分:1)

没有内置方法可以做到这一点。

我通常最终做的方式是使用一个表格,颜色与数据相连,颜色函数或表达式选择颜色。

如果您只有2组或3组,最好的选择可能是使用IIF:

=IIF(FIELDS!GROUP.VALUE = "Group 1", "GRAY", IIF(FIELDS!GROUP.VALUE = "Group 2", "IndianRed", "LightSteelBlue"))

以下是各种方法的很好的例子:

https://www.mssqltips.com/sqlservertip/2797/different-ways-to-create-custom-colors-for-charts-in-sql-server-reporting-services/

如果您正在寻找细节的交替行颜色,请查看:

Add alternating row color to SQL Server Reporting services report

您可以将两者合并到您的细节中:

=Code.AlternateColor(IIF(FIELDS!GROUP.VALUE = "Group 1", "Gray"
 IIF(FIELDS!GROUP.VALUE = "Group 2", "IndianRed", "LightSteelBlue")),
 IIF(FIELDS!GROUP.VALUE = "Group 1", "LightGray", IIF(FIELDS!GROUP.VALUE = "Group 2", "MistyRose", "AliceBlue")), True)