以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]排降序查找前5行 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=85676) |
-- 作者:易服 -- 发布时间:2016/5/31 15:50:00 -- [求助]排降序查找前5行 各村以[补助金额]排降序,然后查找前5行(包括第5行)的数据并导出excel。这个代码怎么写?
[此贴子已经被作者于2016/6/1 15:17:17编辑过]
|
-- 作者:易服 -- 发布时间:2016/5/31 16:17:00 -- 请指教 |
-- 作者:易服 -- 发布时间:2016/5/31 16:36:00 -- 大红袍老师指教 |
-- 作者:大红袍 -- 发布时间:2016/5/31 16:52:00 -- Dim idxs As String = "-1," For Each ary() As String In DataTables("公益林").GetValues("乡|村") Dim count As Integer = 0 For Each dr As DataRow In DataTables("公益林").Select("乡 = \'" & ary(0) & "\' and 村 = \'" & ary(1) & "\'", "补助金额 desc") idxs &= dr("_Identify") & "," count += 1 If count = 5 Then Exit For End If Next Next Tables("公益林").Filter = "_Identify in (" & idxs.trim(",") & ")" Tables("公益林").sort = "乡,村,补助金额 desc" Tables("公益林").SaveExcel("d:\\test.xls", "公益林") |
-- 作者:易服 -- 发布时间:2016/5/31 17:03:00 -- 谢谢!如"公益林级别"区分“省级”“国家级”代码又怎么改? |
-- 作者:大红袍 -- 发布时间:2016/5/31 17:06:00 -- Dim idxs As String = "-1," For Each ary() As String In DataTables("公益林").GetValues("乡|村|公益林级别") Dim count As Integer = 0 For Each dr As DataRow In DataTables("公益林").Select("乡 = \'" & ary(0) & "\' and 村 = \'" & ary(1) & "\' and 公益林级别 = \'" & ary(2) & "\'", "补助金额 desc") idxs &= dr("_Identify") & "," count += 1 If count = 5 Then Exit For End If Next Next Tables("公益林").Filter = "_Identify in (" & idxs.trim(",") & ")" Tables("公益林").sort = "乡,村,公益林级别,补助金额 desc" Tables("公益林").SaveExcel("d:\\test.xls", "公益林") |