If User.IsRole("管理者") Then '------------------------------导入代码------------------------------------- Dim Book As New XLS.Book("E:\质量部数据库\管理项目1\Reports\进货检信息表.xlsx") 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 bjmc As String = sheet(n,0).Text If DataTables("进货检信息表").Find("部件名称= '" & bjmc & "'") Is Nothing Then '如果不存在同编号的订单 Dim r As Row = Tables("进货检信息表").AddNew() For m As Integer = 0 To nms.Length - 1 r(nms(m)) = Sheet(n,m).Value Next End If Next Tables("进货检信息表").ResumeRedraw() Else MessageBox.Show("你不是管理者,无此权限") End If
|