Reporting Service技巧(一):表格中奇偶行不同颜色的设置 |
--金立钢原创,转贴请注明出自微软BI开拓者www.windbi.com
在报表开发中,我们都希望设计出的报表非常美观,就象Excel2007给我们带来的全新的视觉感受一样,让使用者感觉很舒服。 美观性设置中,在报表中奇偶行显示不同的背景颜色就是其中的一种,那么我们就来介绍一下在Reporting Services 2005中如何来实现。 方法一:系统函数 设置所有单元格的背景为如下表达式: backgroudcolor=iif(RowNumber(Nothing) Mod 2, "Lavender", "White") 其中: RowNumber(Nothing):提供了对最外层数据区域中的各行的运行计数值 为了实现更好的通用性,我们可以将此写成一个自定义函数。 方法二:自定义函数 此方法设置得更为巧妙,利用一个全局变量bOddRow来实现奇偶行的切换。 Private bOddRow As Boolean '***************************************************************************** '-- Display green-bar type color banding in detail rows '-- Call from BackGroundColor property of all detail row textboxes '-- Set Toggle True for first item, False for others. '***************************************************************************** Function AlternateColor(ByVal OddColor As String, ByVal EvenColor As String, ByVal Toggle As Boolean) As String If Toggle Then bOddRow = Not bOddRow If bOddRow Then Return OddColor Else Return EvenColor End If End Function 函数设置完成之后,在表格第一列的背景色中设置为: =Code.AlternateColor("Black", "White", True) 其他列设置为: =Code.AlternateColor("Black", "White", False) |
Reporting Service技巧(一):表格中奇偶行不同颜色的设置
最新推荐文章于 2022-02-24 17:19:37 发布