找不到更好的方法,试试笨方法:
增加一个“年月”的表达式列,表达式为:SubString(Convert([日期],'System.String'),1,4) + '年' +
SubString(Convert([日期],'System.String'),6,IIF(SubString(Convert([日期],'System.String'),7,1) In ('-','/'),1,2)) + '月'
Dim dic As New Dictionary(Of String, String)
For Each dr As DataRow In DataTables("表A").DataRows
Dim bds As String = dr("年月") & "_" & dr("业务类型") & "," & dr("执行员工")
bds += "/" & dr("年月") & "_业务量." & dr("业务类型") & "," & dr("业务量")
Dim key As String = dr("客户名称")
If dic.ContainsKey(key)
dic(key) += "/" & bds
Else
dic.Add(key,bds)
End If
Next
Dim bm As String = "汇总"
Dim dtb As New DataTableBuilder(bm)
dtb.AddDef("客户名称", Gettype(String), 32)
For Each s As String In dic("虹桥公司").split("/")
If s.Contains(".")
dtb.AddDef(s.split(",")(0), Gettype(Integer), 32)
Else
dtb.AddDef(s.split(",")(0),Gettype(String), 32)
End If
Next
dtb.Build()
For Each k As String In dic.Keys
Dim dr As DataRow = DataTables(bm).AddNew
dr("客户名称") = k
For Each s As String In dic(k).split("/")
dr(s.split(",")(0)) = s.split(",")(1)
Next
Next
For Each dc As DataCol In DataTables(bm).DataCols
If dc.Name.Contains("业务量.")
dc.Caption = dc.Name.split(".")(0)
End If
Next
DataTables(bm).BuildHeader
Tables(bm).ListMode = True
Tables(bm).AutoSizeCols
MainTable= Tables(bm)
[此贴子已经被作者于2019/8/4 17:03:24编辑过]