Dim excelPath As String = ProjectPath & "Excel文件夹" For Each file As String In FileSys.GetFiles(excelPath) If file Like "*.xls" OrElse file Like "*.xlsx" Dim Book As New XLS.Book(file) '定义一个Excel工作簿 Dim Sheet As XLS.Sheet = Book.Sheets(0) '引用工作簿的第一个工作表 For r As Integer = 0 To sheet.Rows.Count - 1 Dim filter As String = "工程名称 = '" & sheet(r, 0).Text & "' And 任务名称 = '" & sheet(r, 1).Text & "'" Dim fdr As DataRow = DataTables("任务").Find(filter) If fdr IsNot Nothing Then fdr("生产任务") = sheet(r, 4).Text fdr("完成总量") = sheet(r, 5).Text End If Next End If Next