Foxtable(狐表)用户栏目专家坐堂 → 交叉统计


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

主题:交叉统计

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


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

Dim g As New CrossTableBuilder("统计表1", DataTables("小流域统计"))
g.HGroups.AddDef("年度")
g.VGroups.AddDef("措施")
g.Totals.AddDef("数量", "数量")
g.HorizontalTotal = True
g.VerticalTotal = True
g.Build()
Dim t As Table = Tables("统计表1")
Dim sum As Double = 0
For i As Integer = 1 To t.Cols.count-2
    Dim fdr As DataRow = DataTables("小流域统计").Find("措施='" & t.Cols(i).Caption & "'")
    If fdr IsNot Nothing AndAlso fdr("单位") <> "亩" Then
        sum += t.Rows(t.Rows.count-1)(i)
        t.Rows(t.Rows.count-1)(i) = Nothing
    End If
Next
t.Rows(t.Rows.count-1)(t.Cols.count-1) -= sum
MainTable = t

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


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

Dim g As New CrossTableBuilder("统计表1", DataTables("小流域统计"))
g.HGroups.AddDef("年度")
g.VGroups.AddDef("措施")
g.Totals.AddDef("数量", "数量")
g.HorizontalTotal = True
g.VerticalTotal = True
g.filter = "年度 is not null"
g.Build()
Dim t As Table = Tables("统计表1")
Dim allsum As Double = 0
For j As Integer = 0 To t.Rows.count - 2
    Dim r = t.Rows(j)
    Dim sum As Double = 0
    For i As Integer = 1 To t.Cols.count-2
        Dim fdr As DataRow = DataTables("小流域统计").Find("措施='" & t.Cols(i).Caption & "' and 年度 = '" & r("年度") & "'")
        If fdr IsNot Nothing AndAlso fdr("单位") = "亩" Then
            sum += r(i)
        End If
    Next
    r(t.Cols.count-1) = sum
    allsum += sum
Next
t.Rows(t.Rows.count-1)(t.Cols.count-1) = allsum
MainTable = t

 回到顶部