以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 多值字段统计 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=69321) |
||||
-- 作者:实话实说 -- 发布时间:2015/6/3 9:36:00 -- 多值字段统计 第一次需要统计多值字段,帮助里虽有实例,但有点难度,最近确实没有时间研究,还请老师赐予代码 |
||||
-- 作者:Bin -- 发布时间:2015/6/3 9:38:00 -- 帮助代码,照搬就好嘛 http://www.foxtable.com/help/topics/2400.htm 搞不定就上例子.
|
||||
-- 作者:实话实说 -- 发布时间:2015/6/3 10:15:00 --
|
||||
-- 作者:大红袍 -- 发布时间:2015/6/3 10:26:00 -- Dim dt As DataTable Dim dtb As New DataTableBuilder("统计") dtb.AddDef("产品", Gettype(String), 16) dt = dtb.Build() Dim sdt As DataTable = DataTables("表A") For Each cp As String In sdt.GetValues("产品") Dim ndr As DataRow = dt.AddNew ndr("产品") = cp For Each dr As DataRow In sdt.Select("产品 = \'" & cp & "\'") Dim qxs() As String = dr("缺陷").Split(",") For Each qx As String In qxs If dt.DataCols.Contains(qx) = False Then dt.DataCols.Add(qx, Gettype(Integer)) End If ndr(qx) += 1 Next Next Next |
||||
-- 作者:实话实说 -- 发布时间:2015/6/5 22:33:00 -- 多值字段计数统计还是没有搞定,实例窗口中有三种统计类型还请老师帮忙给出代码
|
||||
-- 作者:实话实说 -- 发布时间:2015/6/6 10:28:00 -- 谁帮我5楼的实例 |
||||
-- 作者:实话实说 -- 发布时间:2015/6/6 14:17:00 -- 顶一下 |
||||
-- 作者:y2287958 -- 发布时间:2015/6/6 16:49:00 -- 试试以下代码: 表1 Dim g As New CrossTableBuilder("统计表", DataTables("表B")) g.HGroups.AddDef("缺陷等级") g.VGroups.AddDef("月") g.Totals.AddDef("月", AggregateEnum.Count) g.HorizontalTotal = True g.Build() Tables("统计表").AutoSizeColsMainTable = Tables("统计表") 表2 Dim dtb As New DataTableBuilder("中间表") dtb.AddDef("缺陷原因", Gettype(String), 32) dtb.AddDef("月", Gettype(String), 32) dtb.TableVisible = False dtb.Build() For Each dr As DataRow In DataTables("表B").DataRows For Each s As String In dr("缺陷原因").split(",") Dim dr1 As DataRow = DataTables("中间表").AddNew dr1("缺陷原因") = s dr1("月") = dr("月") Next Next Dim b As New CrossTableBuilder("统计表",DataTables("中间表")) b.HGroups.AddDef("缺陷原因") b.VGroups.AddDef("月") b.Totals.AddDef("月",AggregateEnum.Count) b.HorizontalTotal = True b.Build Tables("统计表").AutoSizeCols MainTable = Tables("统计表") 表3 Dim dtb As New DataTableBuilder("中间表") dtb.AddDef("责任人", Gettype(String), 32) dtb.AddDef("缺陷原因", Gettype(String), 32) dtb.AddDef("月", Gettype(String), 32) dtb.TableVisible = False dtb.Build() For Each dr As DataRow In DataTables("表B").DataRows For Each s As String In dr("缺陷原因").split(",") Dim dr1 As DataRow = DataTables("中间表").AddNew dr1("责任人") = dr("责任人") dr1("缺陷原因") = s dr1("月") = dr("月") Next Next Dim b As New CrossTableBuilder("统计表",DataTables("中间表")) b.HGroups.AddDef("责任人") b.HGroups.AddDef("缺陷原因") b.VGroups.AddDef("月") b.Totals.AddDef("月",AggregateEnum.Count) b.HorizontalTotal = True b.Build Tables("统计表").AutoSizeCols MainTable = Tables("统计表")
|
||||
-- 作者:实话实说 -- 发布时间:2015/6/6 17:39:00 -- 以下是引用y2287958在2015/6/6 16:49:00的发言:
试试以下代码: 表1 Dim g As New CrossTableBuilder("统计表", DataTables("表B")) g.HGroups.AddDef("缺陷等级") g.VGroups.AddDef("月") g.Totals.AddDef("月", AggregateEnum.Count) g.HorizontalTotal = True g.Build() Tables("统计表").AutoSizeColsMainTable = Tables("统计表") 表2 Dim dtb As New DataTableBuilder("中间表") dtb.AddDef("缺陷原因", Gettype(String), 32) dtb.AddDef("月", Gettype(String), 32) dtb.TableVisible = False dtb.Build() For Each dr As DataRow In DataTables("表B").DataRows For Each s As String In dr("缺陷原因").split(",") Dim dr1 As DataRow = DataTables("中间表").AddNew dr1("缺陷原因") = s dr1("月") = dr("月") Next Next Dim b As New CrossTableBuilder("统计表",DataTables("中间表")) b.HGroups.AddDef("缺陷原因") b.VGroups.AddDef("月") b.Totals.AddDef("月",AggregateEnum.Count) b.HorizontalTotal = True b.Build Tables("统计表").AutoSizeCols MainTable = Tables("统计表") 表3 Dim dtb As New DataTableBuilder("中间表") dtb.AddDef("责任人", Gettype(String), 32) dtb.AddDef("缺陷原因", Gettype(String), 32) dtb.AddDef("月", Gettype(String), 32) dtb.TableVisible = False dtb.Build() For Each dr As DataRow In DataTables("表B").DataRows For Each s As String In dr("缺陷原因").split(",") Dim dr1 As DataRow = DataTables("中间表").AddNew dr1("责任人") = dr("责任人") dr1("缺陷原因") = s dr1("月") = dr("月") Next Next Dim b As New CrossTableBuilder("统计表",DataTables("中间表")) b.HGroups.AddDef("责任人") b.HGroups.AddDef("缺陷原因") b.VGroups.AddDef("月") b.Totals.AddDef("月",AggregateEnum.Count) b.HorizontalTotal = True b.Build Tables("统计表").AutoSizeCols MainTable = Tables("统计表") 非常感谢
|