曾经用过,但不是写在DLL中!
比如:
procedure TMainForm.PrintRep(RepFile:String;
DataSrcs:array of TDataSource;
SetMaster:Boolean);
//报表文件名,所用的数据源,是否为主从关系。
另可在设定数据源的过程中,取舍字段及控制字段的显示与否。
procedure TRbReportsForm.SetPipelines(SetMaster:Boolean);
var n:integer;
begin
PipelineCnt := Length(FDataSources);
if PipelineCnt=0 then
Exit;
FreeAllPipelines;
SetLength(RepPipelines, PipelineCnt);
for n:=0 to PipelineCnt-1do
begin
RepPipelines[n]:=TppBDEPipeline.Create(Self);
RepPipelines[n].AutoCreateFields:=false;
RepPipelines[n].UserName:='数据表'+IntToStr(n+1);
RepPipelines[n].Name:='BDEPipeline'+IntToStr(n+1);
RepPipelines[n].DataSource:=FDataSources[n];
if (n>0) and SetMaster then
begin
RepPipelines[n].MasterDataPipeline:=RepPipelines[0];
RepPipelines[n].MasterFieldLinks:='ID';
end;
SetPipelineFlds(RepPipelines[n]);
RepPipelines[n].Open;
end;
end;
procedure TRbReportsForm.SetPipelineFlds(Pipeline : TppBDEPipeline);
var
str : string;
vFld : TField;
pFld : TppField;
n, k : integer;
begin
if Pipeline=nil then
Exit;
with Pipeline.DataSource.DataSetdo
begin
k := FieldCount;
for n:=0 to k-1do
begin
vFld := Fields.Fields[n];
if vFld.Tag<0 then
Continue;
str := vFld.FieldName;
pFld := TppField.Create(nil);
pFld.FieldName := str;
pFld.DataType := ppConvertFieldType(vFld.DataType);//RB自带函数ppDBPipe.pas
pFld.FieldAlias:= vFld.DisplayLabel;
pFld.Sort := false;
pFld.Sortable := false;
Pipeline.AddField(pFld);
end;
end;
end;