Dim dt As Table = Tables("订单")
Dim Book As New XLS.Book(ProjectPath & "Book1.xls") '定义一个Excel工作簿
Dim Sheet As XLS.Sheet = Book.Sheets("sheet1") '引用工作簿的第一个工作表
Dim count As Integer = sheet.Rows.Count
For r As Integer = 0 To count '填入数据
If dt.FindRow("_Identify = " & val(sheet(r,0).value)) >= 0 Then
msgbox("重复操作")
count = -1
Exit For
End If
Next
If count <> -1 Then
If count = 0 Then '本来就没有数据,导出表头
Sheet(0, 0).Value = "_Identify"
For c As Integer = 0 To dt.Cols.Count -1 '添加列标题
Sheet(0, c+1).Value = dt.Cols(c).Name
Next
count += 1
End If
For r As Integer = 0 To dt.Rows.Count - 1 '填入数据
Sheet(r + count, 0).Value = dt.rows(r)("_Identify")
For c As Integer = 0 To dt.Cols.Count -1
Sheet(r + count, c+1).Value = dt.rows(r)(c)
Next
Next
'打开工作簿
Book.Save(ProjectPath & "Book1.xls")
Dim Proc As New Process
Proc.File = ProjectPath & "Book1.xls"
Proc.Start()
End If