Dim dlg As New OpenFileDialog '定义一个新的OpenFileDialog
dlg.Filter= "EXCEL文件|*.xls" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
Dim Book As New XLS.Book(dlg.FileName)
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Tables("采购表").StopRedraw()
Dim Cols1() As String = {"编号","类别","名称","规格","单位","数量","采购价"}
Dim Cols2() As String = {"编号","类别","名称","规格","单位","数量","采购价"}
For dr1 As Integer = 1 To Sheet.Rows.Count -1
Dim dr2 As DataRow =DataTables("采购表").AddNew()
For i As Integer = 0 To Cols1.Length - 1
Select Case Cols2(i)
Case "数量","采购价"
dr2(Cols2(i)) = val(sheet(dr1,i).text)
Case Else
dr2(Cols2(i)) = sheet(dr1,i).text
End Select
Next
Next
Tables("采购表").ResumeRedraw()
End If