procedure QueryToTabFormat(Query1: TQuery;
const FileName: String);
var
sl: TStringList;
i: Integer;
ts: String;
begin
sl:=TStringList.Create;
Query1.First;
try
for i:=0 to Query1.FieldCount-1do
ts:=ts+Query1.Fields.DisplayName+#9;
sl.add(ts);
while not Query1.eofdo
begin
ts:='';
for i:=0 to Query1.FieldCount-1do
begin
ts:=ts+Query1.Fields.AsString+#9;
end;
sl.add(ts);
Query1.Next;
end;
sl.SaveToFile(FileName);
finally
sl.free;
end;
end;