老师,因被统计字段取值不确定,设计一个通用统计,代码如下:
Dim dt As DataTable
dt = DataTables("ysd")
Dim bb As String = "金额" ' 指要统计的数量?金额
Dim bfl As String = "采购方式" ' 指要在表头分类统计的字段
Dim btj As String = "管理部门" ' 指要列表分类统计的项目
'通用统计
Dim i As Integer = 0
Dim Pr1 As List(Of String)
Dim dt0 As fxDataSource
Dim dt1 As fxDataSource
Dim bd0 As New GroupTableBuilder("统计表1",dt)
Dim bd1 As New GroupTableBuilder("统计表1",dt)
Pr1 = Dt.GetValues(bfl)
For Each r As String In Pr1
If r <> Nothing
If i = 0
bd0.Filter = bfl & " = '" & r & "' "
bd0.Groups.AddDef(btj)
bd0.Totals.AddDef(bb,r)
dt0 = bd0.BuildDataSource()
i = i + 1
Else
bd1.Filter = bfl & " = '" & r & "' "
bd1.Groups.AddDef(btj)
bd1.Totals.AddDef(bb,r)
dt1 = bd1.BuildDataSource()
dt0.Combine(btj,dt1,btj)
i = i + 1
End If
End If
Next
Tables("通用时期报表_表").DataSource = dt0
结果会出现重复列,代码错在哪里。怎么实现?感谢