Dim dlg As new OpenFileDialog
dlg.Filter = "Excel文件|*.xls;*.xlsx"
dlg.MultiSelect = True '允许选择多个文件
If dlg.ShowDialog = DialogResult.OK Then
For Each file As String In dlg.filenames
Dim dt As DataTable = DataTables("临时表")
Dim dt1 As DataTable = DataTables("销售订单管理")
Dim book As new XLS.Book(file)
Dim sheet As XLS.Sheet = book.Sheets("Report")
Dim khmc As String = ""
Dim riqi As String = ""
For i As Integer = 3 To sheet.Rows.Count - 1
If sheet(i, 5).Text = "" Then
khmc = ""
Else
If sheet(i, 6).Text = "" Then
If sheet(i, 5).Text = "W12806" Then
khmc = ""
Else
Dim ndr1 As DataRow = dt1.AddNew
ndr1("ABUS香港订单号") = sheet(i, 5).text
ndr1("箱唛") = sheet(i+1, 11).text
khmc = sheet(i, 5).Text
End If
ElseIf khmc > "" Then
If sheet(i, 10).text <> "" Then
If sheet(i, 10).text = "(leaving HK latest mid February 2017)" Then
riqi = sheet(i-1, 10).text
Else
riqi = sheet(i, 10).text
End If
End If
Dim ndr As DataRow = dt.AddNew
ndr("ABUS香港订单号") = khmc
ndr("德国编码") = sheet(i, 5).text
ndr("订单数量") = sheet(i, 8).text
ndr("要求交期") = riqi
ndr("确定交期") = riqi
End If
End If
Next
Next
End If