以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  竖表转水平表代码有问题  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=122669)

--  作者:ZJZK2018
--  发布时间:2018/7/30 22:49:00
--  竖表转水平表代码有问题
竖表转水平表时,增加不了行?

代码如下:
1、

Dim tb As Table = Tables("标录分析_Table3")

Dim g As New GroupTableBuilder("统计表1", DataTables("开标记录B"))

g.Groups.AddDef("开标日期", DateGroupEnum.Year, "")

g.Groups.AddDef("开标日期", "")

g.Groups.AddDef("随机摸球法_中标球号")

g.Totals.AddDef("随机摸球法_中标球号", AggregateEnum.Count, "记录数")

g.GrandProportion = True

g.Filter = "[随机摸球法_中标球号] > 0"

tb.DataSource = g.BuildDataSource

tb.Sort = "年,月"


2、

Dim tb3 As Table = Tables("标录分析_Table3")

Dim tb4 As Table = Tables("标录分析_Table4")

Dim dtb As New DataTableBuilder("B")

dtb.AddDef("", Gettype(String), 32)

dtb.AddDef("", Gettype(String), 32)

For Each nm As String In tb3.DataTable.GetValues("随机摸球法_中标球号")

    dtb.AddDef(nm, Gettype(Double))

Next

dtb.Build()

For Each nm As String() In tb3.DataTable.GetValues("|")

    Dim dr1 As DataRow = DataTables("B").AddNew()

    dr1("") = nm(0)

    dr1("") = nm(1)

    For Each dr2 As DataRow In tb3.DataTable.Select(" = \'" & nm(0) & "\' And = \'" & nm(1) & "\'")

        dr1(dr2("随机摸球法_中标球号")) = dr2("记录数")

    Next

Next

tb4.DataSource = dtb.BuildDataSource



此主题相关图片如下:qq截图20180730224945.png
按此在新窗口浏览图片



--  作者:有点蓝
--  发布时间:2018/7/30 22:56:00
--  
最后加上
tb.AllowEdit = True
tb4.AllowEdit = True

--  作者:有点甜
--  发布时间:2018/7/31 9:09:00
--  

Dim tb3 As Table = Tables("标录分析_Table3")

Dim tb4 As Table = Tables("标录分析_Table4")

Dim dtb As New DataTableBuilder("表B")

dtb.AddDef("年", Gettype(String), 32)

dtb.AddDef("月", Gettype(String), 32)

For Each nm As String In tb3.DataTable.GetValues("随机摸球法_中标球号")

    dtb.AddDef(nm, Gettype(Double))

Next

tb4.DataSource = dtb.BuildDataSource
For Each nm As String() In tb3.DataTable.GetValues("年|月")

    Dim dr1 As Row = tb4.AddNew()

    dr1("年") = nm(0)

    dr1("月") = nm(1)

    For Each dr2 As DataRow In tb3.DataTable.Select("年 = \'" & nm(0) & "\' And 月 = \'" & nm(1) & "\'")

        dr1(dr2("随机摸球法_中标球号")) = dr2("记录数")

    Next

Next


--  作者:ZJZK2018
--  发布时间:2018/7/31 12:35:00
--  
老师出错了:

图片点击可在新窗口打开查看此主题相关图片如下:qq浏览器截图20180731123829.png
图片点击可在新窗口打开查看

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


--  作者:有点甜
--  发布时间:2018/7/31 13:10:00
--  
Dim tb1 As Table = Tables("标录分析_Table1")
Dim tb2 As Table = Tables("标录分析_Table2")
Dim dtb As New DataTableBuilder("水平表")
dtb.AddDef("年", Gettype(String), 32)
dtb.AddDef("月", Gettype(String), 32)
For Each nm As String In tb1.DataTable.GetValues("中标球号")
    dtb.AddDef("c" & nm, Gettype(Double), "", nm)
Next
tb2.DataSource = dtb.BuildDataSource
For Each nm As String() In tb1.DataTable.GetValues("年|月")
    Dim dr1 As Row = tb2.AddNew()
    dr1("年") = nm(0)
    dr1("月") = nm(1)
    For Each dr2 As DataRow In tb1.DataTable.Select("年 = \'" & nm(0) & "\' And 月 = \'" & nm(1) & "\'")
        dr1("c" & dr2("中标球号")) = dr2("记录数")
    Next
Next