For Each file As String In filesys.GetFiles("E:\360极速浏览器下载\工作量")
If file.EndsWith(".xls") Then
Dim filename = file.SubString(file.Length-14,10)
Dim Book As New XLS.Book(file)
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Dim bb As Boolean
For i As Integer = 20 To 50 '行
For k As Integer = 1 To 30 '列
Dim jbbg As String = sheet(i,k).Value '查找 工作总量 关键字
If jbbg.Contains("工作总量") Then '找到关键字后开始循环取出数组中的各项数据
Dim dr As Row =Tables("表A").AddNew
Dim cs() As String = {"值班日期","工作总量","访问量","责任人","工作平台"}
For m As Integer = 0 To cs.Length - 1
'MessageBox.Show("这是从数组中取的第" & m & "次循环值是:" & cs(m))
For n As Integer = 20 To 50 '从行开始循环
For o As Integer = 0 To 40 '从列开始循环
Dim gjj As String = sheet(n,o).value '查找关键字
If gjj.StartsWith(cs(m)) Then
If m =0 Or m=6 Or m=7 Or m=9 Or m=10 Or m=12 Or m=13 Then
dr(cs(m)) = sheet(n,o+1).Text
ElseIf m =1 Or m=8 Or m=11 Or m=14 Or m=15 Or m=16 Or m=17 Or m=18 Then
dr(cs(m)) = sheet(n,o+2).Text
Else
dr(cs(m)) = sheet(n,o+3).Text
End If
Exit For
Else '因为部分表中没有表头部分的日期,无法取出日期则需要将文件名日期引用进来
dr(cs(0)) = filename
End If
Next
Next
Next
bb = True
Exit For
End If
Next
If bb = True Then Exit For
Next
End If
Next
MessageBox.Show("数据导入成功.","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)