汇总参考
Dim t As Table = Tables("项目计划_Table2")
Dim g As Subtotalgroup
t.GroupAboveData = True
t.TreeVisible = True
t.SpillNode = True
t.SubtotalGroups.Clear()
'定义客户分组
g = New Subtotalgroup '定义一个新的分组
g.Aggregate = AggregateEnum.Sum '统计类型为求和
g.GroupOn = "任务专业" '分组列为:任务专业
g.TotalOn = "工期" '统计工期列
g.Caption = "{0}" '设置标题
t.SubtotalGroups.Add(g) '加到分组集合中
g = New Subtotalgroup '定义一个新的分组
g.Aggregate = AggregateEnum.Sum '统计类型为求和
g.GroupOn = "主项名称" '分组列为:主项名称
g.TotalOn = "工期" '统计工期列
g.Caption = "{0}" '设置标题
t.SubtotalGroups.Add(g) '加到分组集合中
g = New Subtotalgroup '定义一个新的分组
g.Aggregate = AggregateEnum.Sum '统计类型为求和
g.GroupOn = "任务类" '分组列为:任务类
g.TotalOn = "工期" '统计工期列
g.Caption = "{0}" '设置标题
t.SubtotalGroups.Add(g) '加到分组集合中
t.Sort = "编号"
t.Subtotal(True) '生成汇总模式
t.DataTable.SysStyles("Subtotal0").FontBold = True
t.DataTable.SysStyles("Subtotal1").FontBold = True
t.DataTable.SysStyles("Subtotal2").FontBold = True
t.DataTable.SysStyles("Subtotal3").FontBold = True
t.DataTable.SysStyles("Subtotal4").FontBold = True
t.DataTable.SysStyles("Subtotal5").FontBold = True
Dim r As Row
static pr1 As Row
static pr2 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
If r.Level = 0 Then
f = "任务类 = '" & r("编号") & "'"
pr1 = r
ElseIf r.level = 1 Then
f = "任务类 = '" & pr1("编号") & "' and 主项名称='" & r("编号") & "'"
pr2 = r
ElseIf r.level = 2 Then
f = "任务类 = '" & pr1("编号") & "' and 主项名称='" & pr2("编号") & "' and 任务专业='" & r("编号") & "'"
End If
Dim k As Date = t.Compute("Min(计划开始日期)",f)
Dim w As Date = t.Compute("Max(计划完成日期)",f)
r("工期") = (w-k).totaldays
r("计划开始日期") = k
r("计划完成日期") = w
End If
Next
甘特图自己做 http://www.foxtable.com/webhelp/scr/2355.htm