如下代码:
interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls,ComObj;type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;
  ExcelApp:  Variant;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
  i: integer;
  m: integer;
  index: integer;
begin
  ExcelApp:=CreateOleObject('Excel.Application');
  ExcelApp.WorkBooks.Open('D:\Demo.xls');
  ExcelApp.workbooks[1].sheets[1].Range['A1:W1'].Font.Bold:=True;
  ExcelApp.Workbooks[1].Sheets[1].Range['A1:W1'].Font.Name:='宋体';
  index:=0;
  for i:=1 to 5000 do
  begin
  if  ExcelApp.workbooks[1].sheets[1].cells[i,1].value= '' then
   ExcelApp.workbooks[1].sheets[1].cells[i,1].value := 11;
   ExcelApp.workbooks[1].sheets[1].cells[i,2].value := 22;
   index := index + 1;
   if index>1 then break;
   end;
  ExcelApp.WorkBooks.Close;
  ExcelApp.Quit;
  ExcelApp:=Unassigned;
end;end.