http://www.delphibbs.com/delphibbs/dispq.asp?lid=759711
看完这一帖,你应该有收获,
写到不同的sheet,就是激活不同的sheet的
-----------------------------------
这是基本的写excel的过程
procedure TForm1.Button1Click(Sender: TObject);
var
msexcellevariant;
wbook,wsheetlevariant;
i,j:integer;
begin
MsExcel:= CreateOleObject('Excel.Application');
WBook:=MsExcel.Application;
wbook.workbooks.add;
WBook.Visible:=True;
WSheet:=WBook.ActiveSheet;
while not table1.Eof do
begin
for i:=1 to table1.recordcount do
begin
for j:=1 to table1.fields.count do
begin
wsheet.cells[i,j]:=table1.Fields[j-1].asstring;
end;
table1.Next;
end;
end;
ExcelApplication1.Save( 'C:/Excel/Demo1.xls' );
ExcelApplication1.Quit;