【问题标题】:SSRS How to change background color after a field in a tablixSSRS如何在tablix中的字段后更改背景颜色
【发布时间】:2015-11-08 23:22:20
【问题描述】:

我有一个包含数百行数据的 tablix 表。我希望在特定条件后立即将背景颜色变为黄色。我该怎么做?

示例 - 我希望所有数据都是黄色的 iif(Fields!pet.Value="cat"),所以 hamster 和 on...

【问题讨论】:

    标签: reporting-services colors background ssrs-tablix


    【解决方案1】:

    您需要更改单元格BackgroundColor 的表达式并记住它是什么。为此,我们需要自定义代码。进入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)
    

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

    【讨论】:

    • 这只会改变猫排的颜色。我希望在 cat row 之后更改背景颜色。
    猜你喜欢
    • 2011-06-26
    • 1970-01-01
    • 2011-11-11
    • 2020-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-15
    • 2015-06-09
    相关资源
    最近更新 更多