'对汇总后的报表,横竖列转换
Dim dtb As New DataTableBuilder("表b")
dtb.AddDef("名称", Gettype(String), 10)
dtb.adddef("合计",Gettype(Double))
For Each v As String In DataTables("表a").GetValues("名称")
dtb.AddDef(v, Gettype(Integer))
Next
dtb.Build()
For Each v As DataCol In DataTables("表a").DataCols
If v.name<>"名称"
Dim dr1 As DataRow = DataTables("表B").AddNew()
dr1("名称") = v.name
For Each y As String In DataTables("表a").GetValues("名称")
Dim dr2 As DataRow=DataTables("表a").find("名称= '" & y & "'")
dr1(y) = dr2(v.name)
Next
End If
Next
' MainTable = Tables("表b")
For Each dr As Row In Tables("表b").Rows
For Each dc As Col In Tables("表B").Cols
If dc.Name <> "合计" And dc.Name <> "名称" Then
dr("合计") =dr("合计") + dr(dc.name)
End If
Next
Next
Tables("窗口1_table1").DataSource=DataTables("表B")
Dim t As Table = Tables("窗口1_table1")
Dim g As Subtotalgroup
t.SubtotalGroups.Clear()
'定义客户分组
g = New Subtotalgroup '定义一个新的分组
g.GroupOn = "*" '注意总计分组用符号*表示.
g.Aggregate = AggregateEnum.Sum '统计类型为求和
Dim zf As String=""
For Each c As Col In Tables("窗口1_table1").Cols
If c.IsNumeric
If zf=""
zf=c.name
Else
zf=zf & "," & c.name
End If
End If
Next
g.TotalOn = zf '统计数量和金额列
g.Caption = "合计" '设置标题
t.SubtotalGroups.Add(g) '加到分组集合中
t.Subtotal()