Basado en:
http://www.clubdelphi.com/foros/showthread.php?t=27767
Y utilizando:
http://www.clubdelphi.com/foros/show...60&postcount=2
Te escribí:
Código Delphi
[-]
procedure DataSetToStream(ADataSet: TDataSet; AStream: TStream; ASeparator: string; AFixedSize: Boolean);
var
i: Integer;
S: string;
begin
if not ADataSet.IsEmpty then
begin
ADataSet.EnableControls;
try
ADataSet.First;
repeat
S := '';
for i := 0 to ADataSet.Fields.Count -1 do
if ADataSet.Fields[i].Visible then
begin
if i > 0 then S := S + ASeparator;
if AFixedSize then
S := S + RPad(ADataSet.Fields[i].DisplayText, ' ', ADataSet.Fields[i].DisplayWidth)
else
S := S + ADataSet.Fields[i].DisplayText;
end;
S := S + #13#10;
AStream.Write(S[1], Length(S));
ADataSet.Next;
until ADataSet.Eof;
finally
ADataSet.DisableControls;
end;
end;
end;
procedure DataSetToFile(ADataSet: TDataSet; AFileName: TFileName; ASeparator: Char; AFixedSize: Boolean);
var
Stream: TStream;
begin
Stream := TFileStream.Create(AFileName, fmCreate);
try
DataSetToStream(ADataSet, Stream, ASeparator, AFixedSize);
finally
Stream.Free;
end;
end;
PROBALO!!.. no lo probé en lo mas mínimo
Por otro lado, te cuento que si te fijas en el primer hilo recomiendo unos componentes míos que hacen esta tarea, por desgracia no puedo publicar el código..
Saludos!