以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]Table如何导出选中的行! (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=125904) |
-- 作者:lunengcheng -- 发布时间:2018/10/9 15:45:00 -- [求助]Table如何导出选中的行! Table里面有一个逻辑列Selcet,现在想实现的功能是,导出时只导出Selcet勾选的列,搜索论坛前面的帖子,看到老师是先过滤筛选后导出; Dim str As String For Each r As Row In Tables("销售").GetCheckedRows str = str & "," & r("_Identify") Next Tables("销售").Filter = "[_Identify] in (" & str.Trim(",") & ")" 因为我的选中列不是GetCheckedRows,而是Selcet列,不知道怎么转换,特请教一下各位老师和前辈!
|
-- 作者:有点甜 -- 发布时间:2018/10/9 15:53:00 -- Dim str As String = "" For Each r As Row In Tables("销售").Rows If r("select") = True Then str = str & "," & r("_Identify") End If Next Tables("销售").Filter = "[_Identify] in (" & str.Trim(",") & ")" |
-- 作者:lunengcheng -- 发布时间:2018/10/9 16:08:00 -- 多谢老师,完美解决,分享完整的代码给大家! --------------------------------------------- \'筛选过滤选中的行成新的table Dim TbName ="添加课程_Table1" Dim str As String = "" For Each r As Row In Tables(TbName).Rows If r("select") = True Then str = str & "," & r("_Identify") End If Next Tables(TbName).Filter = "[_Identify] in (" & str.Trim(",") & ")" \'导出table Dim dlg As New SaveFileDialog \'定义一个新的SaveFileDialog dlg.Filter= "excel文件|*.xls" \'设置筛选器 Dim nd As String = Date.now nd = nd.Replace(":","-") \'将 : 替换为 - nd = nd.Replace(" ","_") \'将 替换为 - dlg.FileName = "添加课程_" & User_Name & "_" & nd & "_全部" If dlg.ShowDialog = DialogResult.Ok Then \'如果用户单击了确定按钮 Dim flg As New SaveExcelFlags flg.RowNumber = True flg.CellStyle = True Tables(TbName).SaveExcel(dlg.FileName, TbName, flg) \'保存文件 Dim Proc As New Process \'定义一个新的Process Proc.File = dlg.FileName \'指定要打开的文件 Proc.Start() End If \'导出后提示 Dim hts As Integer = Tables(TbName).Rows.Count MessageBox.Show("恭喜, 导出完成, 共导出" & hts & "条记录!") |