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


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

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

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


加好友 发短信
等级:幼狐 帖子:104 积分:1139 威望:0 精华:0 注册:2017/9/13 8:43:00
[求助]自定义汇总模式  发帖心情 Post By:2018/1/12 10:45:00 [只看该作者]

老师,请问在帮助的自定义汇总模式中,如果我的分组列有三列(例如:产品,客户,雇员),下面这段代码该怎么改呢??

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("Count(日期)",f)
        v = v & " 订购数量:" & t.Compute("Sum(数量)",f)
        v = v & " 订购金额:" & t.Compute("Sum(金额)",f)
        r("产品") = "产品:" & r("产品") & v
    End
If
Next


需要的效果是,如果是统计汇总第三级时,将前两级的名称补上,如果是统计汇总第二级时,将前一级的名称不上,例如:


PD01 - CS01 - EP01:  订单数量:100

PD01 - CS01 - EP02: 订单数量:100

PD01 - CS01:  订单数量:200


PD01 - CS02 - EP01:  订单数量:100

PD01 - CS02 - EP02: 订单数量:100

PD01 - CS02:  订单数量:200


PD01:  订单数量:400



 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | 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


 回到顶部
帅哥哟,离线,有人找我吗?
狐说八道
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:104 积分:1139 威望:0 精华:0 注册:2017/9/13 8:43:00
  发帖心情 Post By:2018/1/12 11:46:00 [只看该作者]

好的,谢谢有点甜老师

 回到顶部