不知道要多详细,大概写了一下。
procedure TForm1.Button1Click(Sender: TObject);
var
Cell1,Cell2 : Variant;
R : Excel2000.Range;
App : ExcelApplication;
Sheet : _WorkSheet;
Intf : IunKnown;
begin
Ole.DoVerb(0);
Intf := Ole.OleObject.Application;
App := Intf as ExcelApplication;
Sheet := App.WorkSheets.Item[1] as _WorkSheet;
Cell1 := Sheet.Cells.Item[1,1];
Cell2 := Sheet.Cells.Item[5,5];
Sheet.Range[Cell1,Cell2].Merge(False);
Sheet.Cells.Item[1,1].MergeArea.Value := Edit1.Text;
Sheet.Cells.Item[6,6].MergeArea.Value := Edit2.Text;
end;