以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]列排序 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=149367) |
-- 作者:lgj716330 -- 发布时间:2020/4/29 19:19:00 -- [求助]列排序 Dim dtb As New DataTableBuilder("统计") dtb.AddDef("部门名称", Gettype(String), 30) dtb.AddDef("月份", Gettype(String), 6) For Each prd() As String In DataTables("统计表1").GetValues("" & HZ3 & "|成本属性") dtb.AddDef(prd(1) & "_" & prd(0), Gettype(Double)) Next dtb.AddDef("总计", Gettype(Double)) dtb.Build() Tables("汇总报表_Table1").DataSource = dtb.BuildDataSource() \' For Each nm() As String In DataTables("统计表1").GetValues("部门名称|月份") Dim dr As DataRow = DataTables("汇总报表_Table1").AddNew() dr("部门名称") = nm(0) dr("月份") = nm(1) dr("总计") =DataTables("统计表1").Compute("sum(金额)","部门名称 = \'" & nm(0) & "\' and 月份 = \'" & nm(1) & "\'") For Each prd() As String In DataTables("统计表1").GetValues("" & HZ3 & "|成本属性") dr(prd(1) & "_" & prd(0)) = DataTables("统计表1").Compute("Sum(金额)","部门名称 = \'" & nm(0) & "\' and 月份 = \'" & nm(1) & "\' and " & HZ3 & " = \'" & prd(0) & "\' and 成本属性= \'" & prd(1) & "\'") Next Next [此贴子已经被作者于2020/4/29 20:01:31编辑过]
|
-- 作者:有点蓝 -- 发布时间:2020/4/30 8:52:00 -- 试试,加到最后 dim lst as new list(of string) for each c as col in Tables("汇总报表_Table1").colsif c.name.contains("_") then list.add(c.name) next lst.sort() lst.Reverse for i as integer = 0 to lst.count - 1 Tables("汇总报表_Table1").cols(lst(i)).move(2) next
|
-- 作者:lgj716330 -- 发布时间:2020/4/30 9:31:00 -- dim lst as new list(of string) for each c as col in Tables("汇总报表_Table1").colsif c.name.contains("_") then lst.add(c.name) next lst.sort() lst.Reverse for i as integer = 0 to lst.count - 1 Tables("汇总报表_Table1").cols(lst(i)).move(2) next
|
-- 作者:有点蓝 -- 发布时间:2020/4/30 10:25:00 -- 笔误。还有问题么? |
-- 作者:lgj716330 -- 发布时间:2021/2/4 13:58:00 -- Dim lst As new List(of String) For Each c As Col In Tables("统计表2").cols If c.Caption.contains("_") Then Lst.add(c.Caption) Else Lst.add(c.name) Next lst.sort() lst.Reverse For i As Integer = 0 To lst.count - 1 Tables("统计表2").cols(lst(i)).move(2) Next 总提示以下错误,这样的统计表要怎么排序呢,用If c.name.contains("_") Then Lst.add(c.name)或If c.Caption.contains("_") Then Lst.add(c.Caption)都不行 [此贴子已经被作者于2021/2/4 13:58:19编辑过]
|
-- 作者:有点蓝 -- 发布时间:2021/2/4 14:05:00 -- Dim lst As new sortedDictionary(Of String, String) For Each c As Col In Tables("统计表2").cols If c.Caption.contains("_") Then Lst.add(c.Caption,c.name) Else Lst.add(c.name,c.name) Next For i As Integer = 0 To lst.keys.count- 1 Tables("统计表2").cols(lst(lst.keys(i))).move(2) Next |
-- 作者:lgj716330 -- 发布时间:2021/2/4 14:58:00 -- 保存代码时提示 |
-- 作者:有点蓝 -- 发布时间:2021/2/4 15:01:00 -- For each s as string in lst.keys Tables("统计表2").cols(lst(s)).move(2) Next
|