做个按钮,执行代码
Dim dlg As new OpenFileDialog
dlg.Filter = "Excel文件|*.xls;*.xlsx"
If dlg.ShowDialog = DialogResult.OK Then
Dim dt_dd As DataTable = DataTables("订单库")
Dim dt_ddmx As DataTable = DataTables("订单明细")
Dim book As new XLS.Book(dlg.FileName)
Dim sheet As XLS.Sheet = book.Sheets("Report")
Dim khmc As String = ""
For i As Integer = 1 To sheet.Rows.Count - 1
If sheet(i, 5).Text <> "" Then
If sheet(i, 6).Text = "" Then
Dim ndr As DataRow = dt_dd.AddNew
ndr("客户名称") = sheet(i, 5).text
khmc = sheet(i, 5).text
Else
Dim ndr As DataRow = dt_ddmx.AddNew
ndr("编码") = sheet(i, 5).text
ndr("规格") = sheet(i, 6).text
ndr("数量") = sheet(i, 8).text
ndr("客户名称") = khmc
End If
End If
Next
End If