以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  关于导出表的排序问题  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=160264)

--  作者:fvcfox
--  发布时间:2021/1/27 1:42:00
--  关于导出表的排序问题
下面代码的导出表不会按红色代码排序导出,请指教

Tables("统计表").Sort="排名"
Dim dlg As New SaveFileDialog \'定义一个新的SaveFileDialog
dlg.Filter= "Excel文件|*.xls" \'设置筛选器
dlg.FileName = "统计表" & Format(Date.Now, "yyyyMMdd") & ".xls"
If dlg.ShowDialog = DialogResult.Ok Then \'如果用户单击了确定按钮
    Dim ex As New Exporter
    ex.SourceTableName = "统计表" \'指定导出表
    ex.FilePath = dlg.FileName \'指定目标文件
    ex.Format = "Excel" \'导出格式为Excel
Dim str As String
Tables("评价类别").Sort="_Identify DESC"
For Each r As Row In Tables("评价类别").Rows
 str=  ","& r("评价类别") & str
Next
    ex.Fields = "编号,部门,自身类别,姓名" & str & ",合计,排名,等次" \'指定导出字段
    ex.Export() \'开始导出   
    messagebox.show("已完成 [统计表] 的EXCEL导出!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If

--  作者:有点蓝
--  发布时间:2021/1/27 8:32:00
--  
Exporter是根据datatable导出的,不会受table的排序影响