use comobj,clipbrd;
var exapp,exbook,exsheet:variant;
clp:tclipboard;
n:integer;
//dataset:数据集控件
begin
clp:=tclipboard.create;
clp.astext:='报表名称';
clp.astext:=clp.astext+#13+'标题1'+#9+'标题2'+#9+'标题3'...
while not dataset.eofdo
begin
clp.astext:=clp.astext+#13+dataset.fields[0].asstring+#9+dataset.fields [1].asstring+#9+...
dataset.next;
end;
exapp:=createoleobject('excel.application');
exbook:=exapp.workbooks.add;
exsheet:=exapp.activesheet;
exsheet.paste;
exapp.visible:=true;
exsheet.cells[1,1].font.size:=18;
exsheet.range['a1'].select;
exsheet.range['a1','g'+inttostr(n+3)].borders.style:=1;
exsheet:=unassigned;
exbook:=unassigned;
exapp:=unassigned;
end;