部分列,包括指定标题:
Dim dt As Table = Tables("窗口1_表格_Table出入库主表")
Dim nms() As String = {"第一列","第二列","第三列"} '要导出的列名
Dim caps() As String = {"标题一","标题二","标题三"} '对应的标题
For c As Integer = 0 To nms.length -1 '添加列标题
Sheet(0, c).Value = caps(i)
Next
For r As Integer = 0 To dt.Rows.Count - 1 '填入数据
For c As Integer = 0 To nms.length -1
Sheet(r +1, c).Value = dt.rows(r)(nms(c))
Next
Next
Dim dlg As New SaveFileDialog '定义一个新的SaveFileDialog
dlg.Filter= "Excel文件|*.xls" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then
Book.Save(dlg.FileName)
Dim Proc As New Process
Proc.File = dlg.FileName
Proc.Start()
End If