hejsa der...........
Det her er noget jeg har brugt noget af en gang....
det er taget herfra
http://www.gnomehome.demon.nl/uddf/
der ligger en masse gode sager her......
/finn
---------------------------------------------
procedure TfrmBlank.btnExcelClick(Sender: TObject);
var
XL, XArr: Variant;
i : Integer;
j : Integer;
begin
{note the ComObj (example OleAuto not correct) in the uses}
// Create an array of query element size
XArr:=VarArrayCreate([1,EmailQuery.FieldCount],varVariant);
XL:=CreateOLEObject('Excel.Application'); // Ole object creation
XL.WorkBooks.add;
XL.visible:=true;
j := 1;
EmailQuery.First;
while not EmailQuery.Eof do begin
i:=1;
while i<=EmailQuery.FieldCount do begin
XArr[i] := EmailQuery.Fields[i-1].Value;
i := i+1;
end;
XL.Range['A'+IntToStr(j),
CHR(64+EmailQuery.FieldCount)+IntToStr(j)].Value := XArr;
EmailQuery.Next;
j := j + 1;
end;
XL.Range['A1',CHR(64+EmailQuery.FieldCount)+IntToStr(j)].select;
// XL.cells.select; // Select everything
XL.Selection.Font.Name:='Garamond';
XL.Selection.Font.Size:=10;
XL.selection.Columns.AutoFit;
XL.Range['A1','A1'].select;
end;