Dim g As New CrossTableBuilder("统计表", DataTables("学时2013下"))
g.HGroups.AddDef("xq")
g.HGroups.AddDef("zsbh")
g.HGroups.AddDef("xm")
g.VGroups.AddDef("jzfjz")
g.VGroups.AddDef("djnf")
g.VGroups.AddDef("xmmc")
g.Totals.AddDef("xs")
g.HorizontalTotal =1
g.VerticalTotal =1
g.Filter = "xq is not null"
g.Build()
Dim ex1,ex2,s1,s2,s3 As String
Dim dt As DataTable = DataTables("统计表")
dt.StopRedraw
For Each dc As DataCol In dt.DataCols
If dc.Caption.StartsWith("非集中_") Then
ex1+= "+IsNull([" & dc.name & "],0)"
s1+= "|" & dc.name & "|-1"
Else If dc.Caption.StartsWith("集中_") Then
ex2+= "+IsNull([" & dc.name & "],0)"
s2+= "|" & dc.name & "|-1"
End If
Next
s3="xq|-1|zsbh|-1|xm|-1"
If ex1 isnot nothing then
dt.DataCols.Add("非集中小计", Gettype(Integer),ex1.trim("+"))
s3+= s1 & "|非集中小计|-1"
End if
If ex2 isnot nothing then
dt.DataCols.Add("集中小计", Gettype(Integer),ex2.trim("+"))
s3+ =s2 & "|集中小计|-1"
End if
s3+="|合计|-1"
Tables("统计表").SetColVisibleWidth(s3)
dt.ResumeRedraw
MainTable = Tables("统计表")
[此贴子已经被作者于2014-4-3 18:34:03编辑过]