RDLC分组序号

1、RDLC报表表格中添加序号,调用表达式RowNumber( Nothing )

2、RDLC报表,表格分组后添加序号,分两种情况

第一种情况,在分组内添加从1开始的序号,每个分组内都是从1开始计数。

在报表属性-》代码中添加如下代码:

 1 Dim count As Integer
 2 Dim GroupName As String
 3 Public Function GroupCount(name As String) As String
 4 
 5 If (GroupName = "") Then
 6 count = 1
 7 GroupName = name
 8 GroupCount = count
 9 Exit Function
10 End If
11 
12 If (GroupName = name) Then
13 count = count + 1
14 GroupCount = count
15 Else
16 count = 1
17 GroupName = name
18 GroupCount = count
19 Exit Function
20 End If
21 
22 End Function

然后在需要添加序号的表格中添加表达式=Code.GroupCount(Fields!bm.Value)

这种方法,在翻页的时候会重新从1开始计数,目前尚未解决,可以尝试将表格嵌套在矩阵中。

第二种情况,分组外排序,即给组排序,从1开始,每多一个不同的分组添加1,有多少个不同的组,序号就增加到多少。

 1 Dim count As Integer
 2 Dim GroupName As String
 3 Public Function GroupCount(name As String) As String
 4 
 5 If (GroupName = "") Then
 6 count = 1
 7 GroupName = name
 8 GroupCount = count
 9 Exit Function
10 End If
11 
12 If (GroupName = name) Then
13 count = count
14 GroupCount = count
15 Else
16 GroupName = name
17 count = count + 1
18 GroupCount = count
19 End If
20 
21 End Function

然后在需要添加序号的表格中添加表达式=Code.GroupCount(Fields!bm.Value) 

原文地址:https://www.cnblogs.com/lgx5/p/15664208.html