function dbftotxt(tablename:string;const fieldlist:array of string;txtfile:string):boolean;
var
i:integer;
ts:tstringlist;
s:string;
tt:ttable;
begin
ts:=tstringlist.Create ;
tt:=ttable.Create(nil);
try
tt.tablename:= tablename;
tt.Open ;
tt.First;
while not tt.Eof do begin
s:='';
for i:=low(fieldlist) to high(fieldlist) do begin
if tt.FieldByName(fieldlist).DataType=ftstring then begin
if i=high(fieldlist) then s:=s+'"'+tt.Fields.FieldByName(fieldlist).AsString +'"';
if i<high(fieldlist) then s:=s+'"'+tt.Fields.FieldByName(fieldlist).AsString +'",';
end;
if tt.FieldByName(fieldlist).DataType=ftfloat then begin
if i=high(fieldlist) then s:=s+floattostr(tt.Fields.FieldByName(fieldlist).Asfloat);
if i<high(fieldlist) then s:=s+floattostr(tt.Fields.FieldByName(fieldlist).Asfloat)+',';
end;
if tt.FieldByName(fieldlist).DataType=ftinteger then begin
if i=high(fieldlist) then s:=s+inttostr(tt.Fields.FieldByName(fieldlist).Asinteger);
if i<high(fieldlist) then s:=s+inttostr(tt.Fields.FieldByName(fieldlist).Asinteger)+',';
end;
end;
ts.Add(s);
tt.Next ;
end;
ts.SaveToFile(txtfile);
ts.Free ;
tt.Free ;
result:=true;
except
result:=false;
end;
end;
这个是我现在用的一个函数,是DBF转TXT的,你可以参考一下