mark 交叉统计
Dim b As new CrossTableBuilder("单品计划交叉表",DataTables("明细表"))
b.HGroups.AddDef("类别")
b.HGroups.AddDef("编码")
b.HGroups.AddDef("名称")
b.HGroups.AddDef("规格")
b.HGroups.AddDef("单位")
b.HGroups.AddDef("单价")
b.VGroups.AddDef("区域")
b.VGroups.AddDef("门店")
b.Totals.AddDef("数量")
b.Totals.AddDef("金额")
b.HorizontalTotal= True
b.Build
Dim t As Table = Tables("单品计划交叉表")
Dim dq As String = ""
Dim str1 As String = ""
Dim str2 As String = ""
Dim ccount = t.Cols.count-1
Dim i As Integer = 0
Do While i <= ccount
Dim cap As String = t.Cols(i).Caption
If cap.Contains("金额") AndAlso cap.Contains("_合计") = False Then
Dim cdq = cap.Split("_")(0)
If cap.Contains("合计") = False Then
Dim idx As Integer = t.Cols(i).Name.Split("_")(1)
str1 &= "isnull(数量_" & idx & ",0)+"
str2 &= "isnull(金额_" & idx & ",0)+"
End If
If dq > "" AndAlso cdq <> dq Then
t.DataTable.DataCols.Add(dq & "_合计_数量", Gettype(Double),str1.trim("+"))
t.DataTable.DataCols.Add(dq & "_合计_金额", Gettype(Double),str2.trim("+"))
t.Cols(dq & "_合计_金额").Move(i-1)
t.Cols(dq & "_合计_数量").Move(i-1)
ccount += 2
i += 2
str1 = ""
str2 = ""
End If
dq = cdq
End If
i += 1
Loop
MainTable = t