No tengo Delphi a mano y mi fluidez en el lenguaje ya no es lo que era, pero aquí una base de la cual partir:
Código Delphi
[-]
uses ComObj, Clipbrd;
procedure Exportar(DataSet: TDataSet; Archivo: String);
var
Excel, Libro: OleVariant;
CSV: TStrings;
Linea: String;
begin
CSV := TStringList.Create;
try
DataSet.First;
while not DataSet.Eof do
begin
Linea := '';
for I := 0 to DataSet.Fields.Count - 1 do
Linea := Linea + '"' + DataSet.Fields[i].AsString + '"' + #9;
CSV.Add(Linea);
DataSet.Next;
end;
Clipboard.AsText := CSV.Text;
Excel := CreateOleObject('Excel.Application');
Excel.SheetsInNewWorkbook := 1;
Libro := Excel.WorkBooks.Add;
Libro.ActiveSheet.Paste();
Libro.SaveAs(Archivo);
finally
Excel.Quit;
CSV.Free;
end;
end;
LineComment Saludos