pplication1.Workbooks.Add (NULL, 0);
// fill is the first row with field titles
RangeE := ExcelApplication1.ActiveCell;
for I := 0 to Table1.Fields.Count - 1 do
begin
RangeE.Value := Table1.Fields [I].DisplayLabel;
RangeE := RangeE.Next;
end;
// add field data in following rows
Table1.DisableControls;
try
Bookmark := Table1.Bookmark;
try
Table1.First;
Row := 2;
while not Table1.EOF do
begin
RangeE := ExcelApplication1.Range [''A'' + IntToStr (Row),
''A'' + IntToStr (Row)];
for I := 0 to Table1.Fields.Count - 1 do
begin
RangeE.Value := Table1.Fields [I].AsString;
RangeE := RangeE.Next;
end;
Table1.Next;
Inc (Row);
end;
finally
Table1.Bookmark := Bookmark;
end;
finally
Table1.EnableControls;
end;
// format the section
RangeE := ExcelApplication1.Range [''A1'', ''E'' + IntToStr (Row - 1)];
RangeE.AutoFormat (3, NULL, NULL, NULL, NULL, NULL, NULL);
end;
initialization
CoInitialize (nil);
end.