SSRS“斑马条纹”没有按预期工作
为什么不更新“ALT”(用于确定行颜色的变量)(见图)
这是代码:
Private Alt As Boolean
Private cnt as integer
Function Stripe(ByVal NewRow As Boolean, ByVal OddColor as String, ByVal EvenColor as String) As String
If NewRow Then
Alt = Not Alt ' Trip the switch denoting a new row
cnt = cnt + 1
end if
If Alt Then
Return OddColor
Else
Return EvenColor
End If
End Function
Function getalt () as boolean
return alt
end function
function getcnt() as integer
return cnt
end function
这是“背景颜色”中的代码 第一列:
=Code.Stripe(true, "#E7E7E7", "Transparent")
第二到 N 列:
=Code.Stripe(False, "#E7E7E7", "Transparent")
注意,您可能需要在另一个窗口中打开图像才能查看调试输出 - 我使用 getalt & 显示“cnt”和“alt”的值getcnt
Why isn't 'ALT' (variable used to determine row colour) being updated (see pic)
Here is the code:
Private Alt As Boolean
Private cnt as integer
Function Stripe(ByVal NewRow As Boolean, ByVal OddColor as String, ByVal EvenColor as String) As String
If NewRow Then
Alt = Not Alt ' Trip the switch denoting a new row
cnt = cnt + 1
end if
If Alt Then
Return OddColor
Else
Return EvenColor
End If
End Function
Function getalt () as boolean
return alt
end function
function getcnt() as integer
return cnt
end function
here is the code that goes in the 'background color'
first column:
=Code.Stripe(true, "#E7E7E7", "Transparent")
second to N columns:
=Code.Stripe(False, "#E7E7E7", "Transparent")
n.b. you may need to open the image in another window to see the debug output - I'm showing the values of 'cnt' and 'alt' using getalt & getcnt
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看来你把事情搞得太复杂了。您可以使用 RowNumber 来实现备用背景颜色,例如:
请注意,如果您使用分组,YourDataset 也可以是范围。
Looks like you're making things too complicated. You can use RowNumber to achieve alternate background coloring, something like:
Note that YourDataset can also be the scope if you're using grouping.
BGcolor 代码需要在第一列
=IIF(code.getcnt() Mod 2, "#E7E7E7", "Transparent") & Code.Stripe(TRUE, "", "")
和第 2..N 列中的
=IIF(code.getcnt() Mod 2, "#E7E7E7", "Transparent") & Code.Stripe(FALSE, "", "")
我确信代码可以整理:)
The BGcolor code needs to be this in the first column
=IIF(code.getcnt() Mod 2, "#E7E7E7", "Transparent") & Code.Stripe(TRUE, "", "")
and this in the 2nd..N columns
=IIF(code.getcnt() Mod 2, "#E7E7E7", "Transparent") & Code.Stripe(FALSE, "", "")
I'm sure the code can be tidied up :)