Hola Osvaldo!!!
Espero te sirva lo siguiente:
Necesitas de Delphi:
-TForm (obvio!!)
-TQuery
-SaveDialog
-TExcelapplication
Código Delphi
[-]var
LCID, LineNumber, h, s: Integer;
LineString :String; WorkBk : _WorkBook; WorkSheet : _WorkSheet; IIndex : OleVariant;
begin
With SaveDialog1 do
begin
FileName:= '';
Filter:='Excel files|*.XLS;All Files|*.*';
DefaultExt := 'XLS';
Title:= 'Exportando a Excel';
IIndex := 1;
if execute then
begin
LCID := GetUserDefaultLCID;
With ExcelApplication1 do
begin
connect;
try
visible[LCID]:= True;
Workbooks.Add(EmptyParam,LCID); WorkBk := WorkBooks.Item[IIndex]; StandardFontSize[LCID] := 8;
StandardFont[LCID] := 'Arial';
h := 0; s := 0;
With qry do
begin
While not Eof do
begin
s := s + 1;
if h < 3 then begin
h := h+1;
WorkSheet := WorkBk.WorkSheets.Get_Item(h) as _WorkSheet; end
else
begin
WorkBk.Worksheets.Add(EmptyParam, EmptyParam, EmptyParam, EmptyParam,LCID);
WorkSheet := WorkBk.WorkSheets.Get_Item(1) as _WorkSheet; end;
Next;
end
end;
ActiveWorkbook.SaveAs(FileName,xlNormal,'','',false,false,xlNochange,xlUserResolution,False,EmptyPar am,EmptyParam,LCID);
finally
disconnect;
end; end; end; end;
Bye!!!