还是不行,帮我看看吧!
procedure TForm1.Button1Click(Sender: TObject);
var i:integer;
begin
form1.ExcelApplication1.Connect;
form1.ExcelApplication1.Workbooks.Add('c:/count.xls',0);
form1.ExcelWorkbook1.ConnectTo(form1.ExcelApplication1.Workbooks[1]);
form1.ExcelWorksheet1.ConnectTo(form1.ExcelWorkbook1.sheets[1] as _worksheet);
form2.Show;
i:=2;
while {not form1.ADOTable1.eof}i<100do
begin
if (i mod 21)=0 then
begin
// form1.ExcelWorksheet1.Cells.Item[i,1]:='小计';
// form1.ExcelWorksheet1.Cells.Item[i,1].font.color:=clblue;
form1.ExcelWorksheet1.Cells.Item[i,2]:='=sum(b'+inttostr(i-20)+':b'+inttostr(i-1)+')';
form1.ExcelWorksheet1.Cells.Item[i,2].font.color:=clred;
form1.ExcelWorksheet1.Range['a'+inttostr(i),'b'+inttostr(i)].MergeCells:=true;
i:=i+1;
next;
end
else
begin
form1.ExcelWorksheet1.Cells.Item[i,1]:=form1.ADOTable1.Fields[1].Value;
form1.ExcelWorksheet1.Cells.Item[i,2]:=form1.ADOTable1.Fields[10].Value;
i:=i+1;
form1.ADOTable1.Next;
form2.label1.Caption:='共有'+inttostr(form1.ADOTable1.RecordCount)+'条计录,正在计算第'+inttostr(i)+'条....';
form2.Update;
form2.Gauge1.MaxValue:=form1.ADOTable1.RecordCount;
form2.Gauge1.AddProgress(1);
end;
end;
/// form1.ExcelWorksheet1.PrintOut;
form2.Free;
form1.ExcelWorkbook1.SaveCopyAs('c:/111.xls');
form1.ExcelApplication1.ActiveWorkbook.Saved[1]:=true;
form1.ExcelApplication1.Quit;
form1.ExcelApplication1.Disconnect;
showmessage('好了!');
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
ShellExecute(Handle, 'Open', PChar('c:/111.xls'), nil, nil, sw_shownormal);///这句不行!!!!
end;
end.