delphi的Demos/Activex/Oleauto/SrvComp有例子
简单的例子:
procedure myprocedure;
var i:integer;
begin
ExcelApplication1.Connect;
ExcelApplication1.Workbooks.Add(NULL,0);
ExcelWorkbook1.ConnectTo(ExcelApplication1.Workbooks[1]);
ExcelWorksheet1.ConnectTo(ExcelWorkbook1.Sheets[1] as _WorkSheet);
for i:=0 to 20 do
ExcelWorksheet1.Cells.Item[i,i]:=format('x:%d y:%d',[i,i]);
ExcelWorkBook1.SaveCopyAs('c:/windows/desktop/aa.xls');
ExcelWorkBook1.Close(false);
ExcelApplication1.Disconnect;
ExcelApplication1.Quit;
end;