Private
Sub
btn_hd_Click(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Handles
btn_hd.Click
Dim
excel = Reo_excel.CurrentWorksheet
Dim
max_row
As
Integer
Dim
max_col
As
Integer
= 3
max_row = excel.RowCount - 1
excel(0, 2) =
"核对"
excel.SetRowsHeight(0, 1, 30)
For
i = 1
To
max_row
excel(i, 2) =
"0"
Next
Dim
I1, J1, H1
As
String
For
i = 1
To
max_row
I1 =
""
If
excel(i, 0)
Is
Nothing
Then
excel(i, 0) = 0
End
If
I1 = excel(i, 0).ToString
For
j = 1
To
max_row
J1 =
""
H1 =
""
If
excel(j, 1)
Is
Nothing
Then
excel(j, 1) = 0
End
If
J1 = excel(j, 1).ToString
H1 = excel(j, 2).ToString
If
I1 = J1
Then
If
H1 =
"0"
Then
excel.Cells(i, 0).Style.BackColor = Color.Green
excel.Cells(j, 1).Style.BackColor = Color.Green
excel(j, 2) = i + 1 &
"-->"
& j + 1
Exit
For
End
If
End
If
Next
Next
Dim
num
As
Integer
= 1
Dim
c1, c2
As
Color
For
i = 1
To
max_row
c1 = excel.Cells(i, 0).Style.BackColor
If
c1.Name <>
"ff008000"
Then
excel(num, 5) = excel(i, 0).ToString
num += 1
End
If
Next
num = 1
For
i = 2
To
max_row
c2 = excel.Cells(i, 1).Style.BackColor
If
c2.Name <>
"ff008000"
Then
excel(num, 6) = excel(i, 1).ToString
num += 1
End
If
Next
MessageBox.Show(
"双列数据已经核对完成!"
,
"核对提醒"
, MessageBoxButtons.OK, MessageBoxIcon.Information)
End
Sub