以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  这样能实现对临时表汇总吗?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=126929)

--  作者:xxfoxtable
--  发布时间:2018/11/1 9:45:00
--  这样能实现对临时表汇总吗?

Tables("按时间段统计_table1").DataSource=DataTables("表B")

    Dim t As Table = Tables("按时间段统计_table1")
    Dim g As Subtotalgroup
    t.SubtotalGroups.Clear()
    \'定义客户分组
    g = New Subtotalgroup \'定义一个新的分组
    g.GroupOn = "*"   \'注意总计分组用符号*表示.
    g.Aggregate = AggregateEnum.Sum \'统计类型为求和
    Dim zf As String=""
    For Each c As Col In Tables("按时间段统计_table1").Cols
        If c.IsNumeric
            If zf=""
                zf=c.name
            Else
                zf=zf & "," & c.name
            End If
        End If
    Next
    msgbox(zf)
    g.TotalOn =  zf \'统计数量和金额列
    g.Caption = "合计"          \'设置标题
    t.SubtotalGroups.Add(g) \'加到分组集合中
    t.Subtotal()

这样写没有效果呢?


--  作者:有点甜
--  发布时间:2018/11/1 10:05:00
--  

我测试了一下,代码没问题的。

 

实例发上来测试


--  作者:xxfoxtable
--  发布时间:2018/11/1 10:31:00
--  
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:管理项目1.rar


--  作者:有点甜
--  发布时间:2018/11/1 10:35:00
--  

\'对汇总后的报表,横竖列转换
Dim dtb As New DataTableBuilder("表b")
dtb.AddDef("名称", Gettype(String), 10)
dtb.adddef("合计",Gettype(Double))
For Each v As String In DataTables("表a").GetValues("名称")
    dtb.AddDef(v, Gettype(Integer))
Next
dtb.Build()
For Each v As DataCol In DataTables("表a").DataCols
    If  v.name<>"名称"
        Dim dr1 As DataRow = DataTables("表B").AddNew()
        dr1("名称") = v.name
        For Each y As String In DataTables("表a").GetValues("名称")
            Dim dr2 As DataRow=DataTables("表a").find("名称= \'" & y & "\'")
            dr1(y) = dr2(v.name)
        Next
    End If
Next
\' MainTable = Tables("表b")
For Each dr As Row In Tables("表b").Rows
    For Each dc As Col  In Tables("表B").Cols
        If dc.Name <> "合计" And dc.Name <> "名称" Then
            dr("合计") =dr("合计") + dr(dc.name)
        End If
    Next
Next

Tables("窗口1_table1").DataSource=DataTables("表B")
Dim t As Table = Tables("窗口1_table1")
Dim g As Subtotalgroup
t.SubtotalGroups.Clear()
\'定义客户分组
g = New Subtotalgroup \'定义一个新的分组
g.GroupOn = "*"   \'注意总计分组用符号*表示.
g.Aggregate = AggregateEnum.Sum \'统计类型为求和
Dim zf As String=""
For Each c As Col In Tables("窗口1_table1").Cols
    If c.IsNumeric
        If zf=""
            zf=c.name
        Else
            zf=zf & "," & c.name
        End If
    End If
Next

g.TotalOn = zf     \'统计数量和金额列
g.Caption = "合计"          \'设置标题
t.SubtotalGroups.Add(g) \'加到分组集合中
t.Subtotal()