Dim t As Table = Tables("工时")
Dim g As Subtotalgroup
t.SubtotalGroups.Clear()
t.GroupAboveData = False
t.TreeVisible = False
g = New Subtotalgroup
g.Aggregate = AggregateEnum.Sum
g.GroupOn = "自定义"
g.Caption = "{0}"
t.SubtotalGroups.Add(g)
t.Subtotal()
Dim r As Row
For i As Integer = 0 To t.Rows.Count(True) - 1
r = t.Rows(i,True)
If r.IsGroup '如果是分组行
Dim f As String = "姓名 '" & r("姓名") & "'"
Dim v As String = " 工时:" & t.Compute("Sum(工时)",f)
r("姓名") = "姓名:" & r("姓名") & v
End If
Next
Dim b As New GroupTableBuilder("统计表1",DataTables("工时"))
'b.Groups.AddDef("日期",DateGroupEnum.Year,"年") '添加日期列用于分组,并用"年"代替原名称
b.Groups.AddDef("姓名","姓名") '添加日期列用于分组,并用"月"代替原名称
b.Totals.AddDef("工时") '添加数量列用于统计
b.Subtotal = True '生成汇总模式
b.Build '生成统计表
MainTable = Tables("统计表1") '打开生成的统计表
Dim Chart As WinForm.Chart '定义一个图表变量
Dim Series As WinForm.ChartSeries '定义一个图系变量
Dim t1 As Table = Tables("工时") '定义一个变量t引用数据表
Chart= Forms("自定义生成图表").Controls("Chart1") ' 引用窗口中的图表
'Chart = e.Form.Controls("Chart1") ' 引用窗口中的图表
Chart.ChartType = ChartTypeEnum.Bar '图表类型该为Bar(条形)
Chart.DataSource = t1.DataTable.Name '设置绑定表
Chart.SeriesList.Clear() '清除图表原来的图系
Series = Chart.SeriesList.Add() '增加一个图系
Series.X.DataField = Forms("自定义生成图表").controls("TextBox1").value 'X轴绑定到产品列
Series.Y.DataField = Forms("自定义生成图表").controls("TextBox2").value 'Y轴绑定到数量列
Series.DataLabelText = "{#YVAL}"