H
hunterduan
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.Button1Click(Sender: TObject);
begin
Myexcel:=CreateOleObject('Excel.Application'); //打开Excel 文档,并记录下地原始记录个数。
if OpenDialog1.Execute then
MyWorkbook := MyExcel.Workbooks.Open(OpenDialog1.FileName);
MyExcel.Visible := true;
i:=MyExcel.worksheets[1].UsedRange.Rows.Count;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
l,m,n,g:integer;
str1,str2:string;
begin
k:=0;
MyExcel.WorkSheets[1].Activate;
Myexcel.worksheets[1].refrsh;
j:=MyExcel.WorkSheets[1].UsedRange.Rows.Count;
l:=j-i;
if l=0 then
begin
ShowMessage('您已经输入数据了吗? 请检查!!');
MyExcel.Visible := true;
//这里没问题。
end
else
begin
if (l<>1) then
begin
for n:=j downto i do
begin
str1:=Myworkbook.Cells[j,1].value;
for m:=i downto 1 do
begin
str2:=Myworkbook.cells[m,1].value;
g:=CompareStr(str1,str2);
if g=0 then
begin
k:=k+1;
myworkbook.cells[j,1].font.color:=ClLime;
end;
end;
end;
end
else
begin
for n:=j downto i do
begin
str1:=Myworkbook.Cells[j,1].value;
for m:=i downto 1 do
begin
str2:= Myworkbook.Cells[i,1].value;
g:=CompareStr(str1,str2);
if g=0 then
begin
k:=k+1;
myworkbook.cells[j,1].font.color:=ClLime;
end;
end;
end;
end;
end;
label2.Caption:=IntToStr(k);
end;
end.
begin
Myexcel:=CreateOleObject('Excel.Application'); //打开Excel 文档,并记录下地原始记录个数。
if OpenDialog1.Execute then
MyWorkbook := MyExcel.Workbooks.Open(OpenDialog1.FileName);
MyExcel.Visible := true;
i:=MyExcel.worksheets[1].UsedRange.Rows.Count;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
l,m,n,g:integer;
str1,str2:string;
begin
k:=0;
MyExcel.WorkSheets[1].Activate;
Myexcel.worksheets[1].refrsh;
j:=MyExcel.WorkSheets[1].UsedRange.Rows.Count;
l:=j-i;
if l=0 then
begin
ShowMessage('您已经输入数据了吗? 请检查!!');
MyExcel.Visible := true;
//这里没问题。
end
else
begin
if (l<>1) then
begin
for n:=j downto i do
begin
str1:=Myworkbook.Cells[j,1].value;
for m:=i downto 1 do
begin
str2:=Myworkbook.cells[m,1].value;
g:=CompareStr(str1,str2);
if g=0 then
begin
k:=k+1;
myworkbook.cells[j,1].font.color:=ClLime;
end;
end;
end;
end
else
begin
for n:=j downto i do
begin
str1:=Myworkbook.Cells[j,1].value;
for m:=i downto 1 do
begin
str2:= Myworkbook.Cells[i,1].value;
g:=CompareStr(str1,str2);
if g=0 then
begin
k:=k+1;
myworkbook.cells[j,1].font.color:=ClLime;
end;
end;
end;
end;
end;
label2.Caption:=IntToStr(k);
end;
end.