2个dbgrid 通过2个adotable 装载了2个Excel,我现在想要对这两个excel互相查重
我用一个stringgrid的2列,分别取2个excel的列名,也就是字段名称,然后对每行的2个字段匹配查重
该用什么算法呢?
excel1:                               Excel2:
  xh   xh1  xh2  xh3   xh4                lb    lb1   lb2  lb3  lb4  lb5 
  1    123  234  1212  123                 1     2     1    2    12   123
  2     a    b    c     d                  2     b     c    d    e     f  
  3     b    c    d     e                  3     c     d    e    f     g
  4     2    3    3     4                  4     4     4    44   44    44stringgird
   excel1字段       excel2字段
      xh               lb
     xh1               lb1
     xh2              lb2
我现在的基础代码是这样的:
  var :str1,str2,str3,str4:string;
       i:integer;
   for i:=1 to stringgrid.RowCount do
   begin
    if (stringgrid.Cells[0,i]<>'') and (stringgrid.Cells[1,i]<>'') then
    begin
      str1:=sg.Cells[0,i] ;
      str2:=sg.Cells[1,i] ;
    end;
  end;
  with adotable1 do
  begin
     first ;
     while not eof do
     begin
       with adotable2 do
       begin
          first; 
          while not eof do
          begin
              str3:=adotable1.fieldbyname(str1).asstring;
              str4:=adotable2.fieldbyname(str2).asstring;
             if str3=str4 then
             begin
                
             end;
            next;
          end;
       end;
       next;
     end ;
  end;