如下代码,标红部分可能有问题,执行是提示:给定关键字不在字典中。见截图A列单元格去除空格后存入字典,第二张图A列内容去除空格与字典匹配,匹配到即填充到对应行的B列
‘字典信息
For i As Integer = 0 To Sheet.Rows.Count-1
If dic.ContainsKey(Sheet(i, 0).Text.Replace(" ","")) = False Then
dic.add(Sheet(i, 0).Text.Replace(" ",""),Sheet(i, 1).Text)
End If
Next
‘批量配配
For Each file As String In FileSys.GetFiles(path)
Dim Book1 As New XLS.Book(file)
For k As Integer = 0 To Book1.Sheets.Count-1 '//多个sheet的处理
Dim Sheet1 = Book1.Sheets(k)
If Sheet1.Cols.Count <> 16384 Then
For i As Integer = 0 To Sheet1.Rows.Count-1
For j As Integer = 0 To Sheet1.Cols.Count -1
If Sheet1(i, j).Text > "" AndAlso dic.ContainsKey(Sheet1(i, j).Text.replace(" ","")) Then
Sheet1(i, j).Value = Sheet1(i, j).Text & "|" & dic(Sheet1(i, j).Text)
End If
Next
Next
'//保存
Book1.Save(file)
'FileCount=FileCount+1
End If
Next
FileCount=FileCount+1
Next

此主题相关图片如下:11.jpg


此主题相关图片如下:22.jpg