多谢老师,完美解决,分享完整的代码给大家!---------------------------------------------
'筛选过滤选中的行成新的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 & "条记录!")