Dim dlg As
New OpenFileDialog '定义一个新的OpenFileDialog
dlg.Filter= "Excel文件|*.xls|Word文件|*.doc|Access文件|*.mdb"
'设置筛选器
If dlg.ShowDialog = DialogResult.Ok
Then
'如果用户单击了确定按钮
If FileSys.FileExists(dlg.FileName) Then
Dim Book As New XLS.Book(dlg.FileName)
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Tables("入库主表.入库明细").StopRedraw()
'注意以下数组中列名称的顺序,必须和Excel表中的列顺序一致
Dim nms() As String = {"料号","数量"}
'注意下面的循环变量从1开始,而不是从0开始,因为Excel表的第一行是标题
For n As Integer = 1 To Sheet.Rows.Count -1
Dim r As Row = Tables("入库主表.入库明细").AddNew()
For m As Integer = 0 To nms.Length - 1
r(nms(m)) = Sheet(n,m).Value
Next
Next
Tables("入库主表.入库明细").ResumeRedraw()
FileSys.MoveFile(dlg.FileName, "d:\入库订单\已导入\订单.xls")
End
If