Dim StartDate As Date = e.Form.Controls("StartDate").value
Dim EndDate As Date = e.Form.Controls("EndDate").value
Dim b As New CrossTableBuilder("统计表1",DataTables("冲压车间工资表"))
b.HGroups.AddDef("订单号")
b.HGroups.AddDef("产品名称")
b.HGroups.AddDef("生产工序")
b.HGroups.AddDef("备注")
b.VGroups.AddDef("日期","{0}月")
b.Totals.AddDef("数量")
b.Totals.AddDef("分配金额")
b.Filter = "日期 >= #" & StartDate & "# And 日期 <= #" & EndDate & "#"
'b.Subtotal = True '生成汇总模式
b.Build() '生成统计表
'MainTable = Tables("统计表1")
Dim Table1 As WinForm.Table = e.Form.Controls("Table1")
Table1.Table.datasource = Tables("统计表1").DataTable '打开生成的统计表
Dim g As New Subtotalgroup '定义一个新的分组
g.Aggregate = AggregateEnum.Sum '统计类型为求和
g.GroupOn = "订单号" '分组列为客户列
g.TotalOn = "数量_1,分配金额_1" '对数量和金额进行统计
g.Caption = "{0} 小计" '设置标题
Table1.Table.SubtotalGroups.Clear() '清除原有的分组
Table1.Table.SubtotalGroups.Add(g)'加入刚刚定义的分组
Table1.Table.Subtotal() '生成汇总模式