proceduce BackupTableToCSV(tableName:TTable);
var
i,j: integer; (*i-field, j-record*)
s: string; (*Record string*)
theStringList: Tstringlist; (*temp storage*)
begin
s:='';
theStringList:=TStringList.Create;
with tableName do
begin
try
Active:=True;
except
showmessage('Could not activate '+ Name);
end;
for j:=0 to (RecordCount-1) do
begin
s:='';
for i:=1 to (FieldCount-1) do
begin
(*add next field w/comma delimiter*)
s:=s+(Fields[i].AsString)+','; //以","分隔,也可以用#9代替
end; (*i for*)
theStringList.add(s);
Next;
end; (*i for*)
theStringList.savetofile
(Name+'.csv'); (*memo1.lines.*)
Showmessage(Name+ ' has been backed up.');
close;
end; (*with*)
end; (*BackupTableToCSV*)
//如果要加入公式,可以这样
在某一行某一列:=sum(B2:B30)
定位列就在前面加","
联系客服