Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reporting services SSRS如何在tablix中的字段后更改背景色_Reporting Services_Colors_Background_Ssrs Tablix - Fatal编程技术网

Reporting services SSRS如何在tablix中的字段后更改背景色

Reporting services SSRS如何在tablix中的字段后更改背景色,reporting-services,colors,background,ssrs-tablix,Reporting Services,Colors,Background,Ssrs Tablix,我有一个包含数百行数据的tablix表。我想有一个特定的条件后,背景颜色是黄色的权利。我该怎么做 示例-我希望所有数据都是黄色的iif(Fields!pet.Value=“cat”),所以仓鼠等等 您需要更改单元格背景颜色的表达式,并记住它是什么。我们需要自定义代码。转到Report菜单,选择Report Properties…并单击code并输入以下代码: Dim ThisPetColor As String Function PetColor(PetType As String) As S

我有一个包含数百行数据的tablix表。我想有一个特定的条件后,背景颜色是黄色的权利。我该怎么做

示例-我希望所有数据都是黄色的iif(Fields!pet.Value=“cat”),所以仓鼠等等


您需要更改单元格背景颜色的表达式,并记住它是什么。我们需要自定义代码。转到
Report
菜单,选择
Report Properties…
并单击
code
并输入以下代码:

Dim ThisPetColor As String

Function PetColor(PetType As String) As String
    If ThisPetColor = "" Then
        ThisPetColor = "White"
    End If

    If PetType = "cat" Then
        ThisPetColor = "Yellow"
    Else If PetType = "hamster" Then
        ThisPetColor = "Green"
    Else If PetType = "unicorn" Then
        ThisPetColor = "Purple"
    End If

    Return ThisPetColor 
End Function
然后在单元格中使
BackgroundColor
表达式为:

=Code.PetColor(Fields!pet.Value)
或者,为了更灵活地复制公式,请使用文本框的内置
Me
参考:

=Code.PetColor(Me.Value)

因此,我们要做的是为pet颜色创建一个全局变量,并将其初始化为“白色”。当宠物的类型改变时,如果它是我们改变颜色的类型之一,那么我们将全局变量的值更改为新的宠物颜色,然后使用它(直到下一个宠物类型)

这只会改变猫行的颜色。我想改变背景颜色后,猫行和。