if sList.Count>0 then begin DSetMain.Close; DSetMain.FieldDefs.Clear; for i:=0 to sList.Count-1 do begin if DSetMain.FieldDefs.IndexOf(GetText('ID',sList.Strings[i]))=-1 then DSetMain.FieldDefs.Add(GetText('ID',sList.Strings[i]),ftString,256,false); end; DSetMain.CreateDataSet; FRReport.Dictionary.FieldAliases['DSetMain']:='主表数据'; DSetMain.Edit; for i:=0 to sList.Count-1 do begin DSetMain.Fields.Fields[i].Value:=GetText('VALUE',sList.Strings[i]); end;
楼主,要打印变量,直接为它赋值不就完了吗,还要建啥子表。真搞不懂。 procedure TForm1.frReport1GetValue(const ParName: String; var ParValue: Variant); begin if ParName='CustomVar' then ParValue := '变量值' end;
if sList.Count>0 then
begin
DSetMain.Close;
DSetMain.FieldDefs.Clear;
for i:=0 to sList.Count-1 do
begin
if DSetMain.FieldDefs.IndexOf(GetText('ID',sList.Strings[i]))=-1 then
DSetMain.FieldDefs.Add(GetText('ID',sList.Strings[i]),ftString,256,false);
end;
DSetMain.CreateDataSet; FRReport.Dictionary.FieldAliases['DSetMain']:='主表数据';
DSetMain.Edit;
for i:=0 to sList.Count-1 do
begin
DSetMain.Fields.Fields[i].Value:=GetText('VALUE',sList.Strings[i]);
end;
procedure TForm1.frReport1GetValue(const ParName: String;
var ParValue: Variant);
begin
if ParName='CustomVar' then
ParValue := '变量值'
end;
有些特殊的原因,需要把这些变量变成单条记录的数据集,比如这些变量个数很多的情况下;还有就是这些变量变成数据集之后,使用非常方便,再加上使用中文字段,非常适合用户自定义报表。