如果是汇总模式,只有第一个表有合计:
此主题相关图片如下:汇总模式.png
Dim filter,filter2 As String
Dim bd1 As New SQLGroupTableBuilder("统计表1","表A")
Dim dt1 As fxDataSource
bd1.Groups.AddDef("部门名称","单位") '统计表1的列重命名
bd1.Totals.AddDef("部门名称", AggregateEnum.Count,"数量_性质")
bd1.FromServer = True
'bd1.VerticalTotal = True '
bd1.Subtotal = True
bd1.Filter = Filter
'dt1 = bd1.BuildDataSource()
'bd1.Build
dt1 = bd1.BuildDataSource()
Dim bd2 As New SQLGroupTableBuilder("统计表2","表C")
Dim dt2 As fxDataSource
bd2.Groups.AddDef("部门名称","单位") '统计表1的列重命名
bd2.Totals.AddDef("部门名称", AggregateEnum.Count,"数量_类别")
'bd2.VerticalTotal = True
bd2.Filter = Filter2
bd2.Subtotal = True
bd2.FromServer = True
dt2 = bd2.BuildDataSource()
dt1.Combine("单位",dt2,"单位") '将统计表2组合到统计表1
'
Tables(e.Form.Name & "_Table1").DataSource = dt1 '将统计结果绑定到Table
'问题:以合计模式生成,不能把合计结果导出至XLS
'Tables(e.Form.Name & "_Table1").Cols("数量_性质").GrandTotal = True '指定要合计的列
'Tables(e.Form.Name & "_Table1").Cols("数量_类别").GrandTotal = True
'Tables(e.Form.Name & "_Table1").GrandTotal = True '显示合计模式
e.Form.Controls("Table1").Visible = True
Tables(e.Form.Name & "_Table1").DataTable.SysStyles("EmptyArea").BackColor = e.Form.BackColor