Dim path As String = args(0)
Dim app As new MsExcel.Application
Dim dic As new Dictionary(of String,String)
Dim dicfile As String = Forms("窗口1").Controls("TextBox2").value
Dim Book As New XLS.Book(dicfile) '定义一个Excel工作簿
Dim Sheet As XLS.Sheet = Book.Sheets(0) '引用工作簿的第一个工作表
For i As Integer = 0 To Sheet.Rows.Count-1
If dic.ContainsKey(Sheet(i, 0).Text.ToLower.Replace(" ","").Replace(chr(10), "").Replace(chr(13), "")) = False Then
dic.add(Sheet(i, 0).Text.ToLower.Replace(" ","").Replace(chr(10), "").Replace(chr(13), ""),Sheet(i, 1).Text)
End If
Next
'For Each k As String In dic.Keys '显示所有键及其对应的值
'Output.Show(K & "|" & dic(k))
'Next
'Dim file As object
'//开始
For Each file As String In FileSys.GetFiles(path)
If file.EndsWith(".xls") OrElse file.EndsWith(".xlsx") Then
Dim wb=app.WorkBooks.Open(file)
'Dim Book1 As New XLS.Book(file)
For k As Integer = 1 To wb.worksheets.count '//多个sheet的处理
Dim ws As msexcel.worksheet=wb.worksheets(k)
Dim rg As msexcel.range=ws.usedrange
If rg.Count = 1 And rg(1).Value = "" Then
'msgbox("空")
Continue For
End If
Dim ary =rg.value
For i As Integer = 1 To rg.Rows.Count
For j As Integer = 1 To rg.Columns.count
'If i= 2 Then
'Continue For
'AndAlso Typeof ary(i,j) Is String
If ary(i,j) <> Nothing AndAlso Typeof ary(i,j) Is String AndAlso dic.ContainsKey(ary(i,j).ToLower.Replace(" ","").Replace(chr(10), "").Replace(chr(13), "")) Then
If Forms("窗口1").Controls("RBt1").checked Then
ws.Cells(i, j).Value = ary(i,j) & "|" & dic(ary(i,j).ToLower.Replace(" ","").Replace(chr(10), "").Replace(chr(13), ""))
End If
End If
'End If
Next
Next
Next
wb.save()
app.quit()
End If
Next
For Each p As String In FileSys.GetDirectories(path)
Functions.Execute("对比函数", p)
Next