Foxtable(狐表)用户栏目专家坐堂 → [求助]自定义汇总模式


  共有2004人关注过本帖树形打印复制链接

主题:[求助]自定义汇总模式

帅哥哟,离线,有人找我吗?
有点甜
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/1/12 11:09:00 [显示全部帖子]

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)
g = New Subtotalgroup
g.Aggregate = AggregateEnum.Sum
g.GroupOn = "客户"
g.Caption = "{0}"
t.SubtotalGroups.Add(g)
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 '如果是分组行
        If r.Level = 0 Then
            Dim f As String = "产品 = '" & r("产品") & "'"
            Dim v As String = " 订单数:" & t.Compute("Count(日期)",f)
            v = v & " 订购数量:" & t.Compute("Sum(数量)",f)
            v = v & " 订购金额:" & t.Compute("Sum(金额)",f)
            r("产品") = r("产品") & ":" & v
        ElseIf r.Level = 1 Then
            Dim pr As Row = t.Rows(r.Index-2, True)
            Dim f As String = "产品 = '" & pr("产品") & "' and 客户 = '" & pr("客户") & "'"
            Dim v As String = " 订单数:" & t.Compute("Count(日期)",f)
            v = v & " 订购数量:" & t.Compute("Sum(数量)",f)
            v = v & " 订购金额:" & t.Compute("Sum(金额)",f)
            r("产品") = pr("产品") & "-" & pr("客户") & ":" & v
        ElseIf r.Level = 2 Then
            Dim pr As Row = t.Rows(r.Index-1, True)
            Dim f As String = "产品 = '" & pr("产品") & "' and 客户 = '" & pr("客户") & "' and 雇员 = '" & pr("雇员") & "'"
            Dim v As String = " 订单数:" & t.Compute("Count(日期)",f)
            v = v & " 订购数量:" & t.Compute("Sum(数量)",f)
            v = v & " 订购金额:" & t.Compute("Sum(金额)",f)
            r("产品") = pr("产品") & "-" & pr("客户") & "-" & pr("雇员") & ":" & v
        End If
    End If
Next


 回到顶部