H
happycyp
Unregistered / Unconfirmed
GUEST, unregistred user!
在dll中定义了一个调用FastReport的类,然后用哪下方法调用:
function TPrintReport.PrintReport2(AData: OleVariant;
AParam: OleVariant;
AFileName: WideString;
IsPreview: Boolean = True): boolean;
var
AFile: WideString;
MasterData: TfrxMasterData;
DetailData: TfrxDetailData;
begin
Result := False;
AFile := ReportDir + AFileName;
{如果文件名没有扩展名,则加上扩展名}
if UpperCase(RightStr(AFile,4)) <> '.FR3' then
AFile := AFile + '.fr3';
if VarIsNull(AData) then
begin
Info(0, '没有数据!');
Exit;
end;
//fReport.ParentFont := False;
try
fReport.LoadFromFile(AFile);
cdsMaster.Data := AData[0];
cdsDetail.Data := AData[1];
fDsMaster.DataSet := cdsMaster;
fDsDetail.DataSet := cdsDetail;
//fReport.DataSets.Add(fDsMaster);
//fReport.DataSets.Add(fDsDetail);
MasterData := fReport.FindObject('MasterBill') as TfrxMasterData;
DetailData := fReport.FindObject('DetailBill') as TfrxDetailData;
MasterData.DataSet := fDsMaster;
DetailData.DataSet := fDsDetail;
if not IsPreview then
begin
fReport.PrepareReport;
fReport.Print;
end else
begin
fReport.PrepareReport;
fReport.ShowReport;
end;
Result := True;
except
on E: Exceptiondo
ErrorMsg(0,E.Message);
end;
end;
结果发现给带区赋数据集不管用。MasterData,DetailData两个带区根本看不到。
请问如何解决。
报表中,已经为相关Memo设置了DataField.
function TPrintReport.PrintReport2(AData: OleVariant;
AParam: OleVariant;
AFileName: WideString;
IsPreview: Boolean = True): boolean;
var
AFile: WideString;
MasterData: TfrxMasterData;
DetailData: TfrxDetailData;
begin
Result := False;
AFile := ReportDir + AFileName;
{如果文件名没有扩展名,则加上扩展名}
if UpperCase(RightStr(AFile,4)) <> '.FR3' then
AFile := AFile + '.fr3';
if VarIsNull(AData) then
begin
Info(0, '没有数据!');
Exit;
end;
//fReport.ParentFont := False;
try
fReport.LoadFromFile(AFile);
cdsMaster.Data := AData[0];
cdsDetail.Data := AData[1];
fDsMaster.DataSet := cdsMaster;
fDsDetail.DataSet := cdsDetail;
//fReport.DataSets.Add(fDsMaster);
//fReport.DataSets.Add(fDsDetail);
MasterData := fReport.FindObject('MasterBill') as TfrxMasterData;
DetailData := fReport.FindObject('DetailBill') as TfrxDetailData;
MasterData.DataSet := fDsMaster;
DetailData.DataSet := fDsDetail;
if not IsPreview then
begin
fReport.PrepareReport;
fReport.Print;
end else
begin
fReport.PrepareReport;
fReport.ShowReport;
end;
Result := True;
except
on E: Exceptiondo
ErrorMsg(0,E.Message);
end;
end;
结果发现给带区赋数据集不管用。MasterData,DetailData两个带区根本看不到。
请问如何解决。
报表中,已经为相关Memo设置了DataField.