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 App As New MSExcel.Application
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open("dlg.FileName")
Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1)
Dim Rg As MSExcel.Range = Ws.Columns("C") '引用C列
Rg.NumberFormat = "h:mm:ss" '时间
App.Visible = False
App.Quit
Dim Proc As New Process
Proc.File = dlg.FileName
Proc.Start()
End If