循环excel的每一行判断,类似代码
Dim dlg As New OpenFileDialog '定义一个新的OpenFileDialog
dlg.Filter= "Excel文件|*.xls;*.xlsx" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
Dim book As new XLS.Book(dlg.FileName)
Dim sheet As XLS.Sheet = book.Sheets(0)
Dim ls As new List(of String)
Dim style As XLS.style = book.NewStyle
style.BackColor = color.red
For i As Integer = 0 To sheet.rows.count-1
Dim bj As String = sheet(i,0).text
Dim xm As String = sheet(i,1).text
If ls.Contains(bj & "|" & xm) = False Then
ls.add(bj & "|" & xm)
Else
sheet(i,0).Style = style
sheet(i,1).Style = style
End If
Next
book.save(dlg.FileName)
Dim proc As new Process
proc.File = dlg.FileName
proc.Start
End If