Registriert seit: 8. Jun 2009
Ort: Bayern
1.138 Beiträge
Delphi 11 Alexandria
|
AW: FastReport by Code, Werte manipulieren
22. Mär 2023, 13:40
ich denke die Lösung müsste so ungefähr gehen ...
habt Ihr Inputs ?
Delphi-Quellcode:
procedure TForm2.BitBtn_FastReportClick(Sender: TObject);
var
Report: TfrxReport;
Page: TfrxReportPage;
DataPage: TfrxDataPage;
NewDataPage: TfrxDataPage;
NewPage: TfrxReportPage;
Band: TfrxBand;
NewBand: TfrxBand;
DataBand: TfrxMasterData;
Memo: TfrxMemoView;
Memo_1: TfrxMemoView;
Memo_2: TfrxMemoView;
Memo_3: TfrxMemoView;
Memo_4: TfrxMemoView;
Memo_L: TfrxMemoView;
DataSet: TfrxDataset;
frxDBDataSet: TfrxDBDataset;
PictureView: TfrxPictureView;
Frxdataset: TfrxDataset;
ItemIndex: Integer;
ItemCount: Integer;
I: Integer;
DBImagefilename: String;
DBType, DBObjectName: String;
begin
FileName := LabeledEdit.text;
Report := TfrxReport.Create(nil);
try
{ add a dataset to the list of ones accessible for a report }
Report.DataSets.Add(frxDBDataset1);
DataPage := TfrxDataPage.Create(Report);
{ add a page }
Page := TfrxReportPage.Create(Report);
{ create a unique name }
Page.CreateUniqueName;
{ set sizes of fields, paper and orientation by default }
// Page.SetDefaults;
{ add a report title band }
Band := TfrxReportTitle.Create(Page);
Band.CreateUniqueName;
{ it is sufficient to set the «Top» coordinate and height for a band }
{ both coordinates are in pixels }
Band.Top := 0;
Band.Height := 20;
{ add an object to the report title band }
Memo := TfrxMemoView.Create(Band);
Memo.CreateUniqueName;
Memo.text := 'Hello FastReport with loop dataset ';
Memo.Height := 20;
{ this object will be stretched according to band’s width }
Memo.Align := baWidth;
NewDataPage := TfrxDataPage.Create(Report);
///
/// 30 eigene Datensätze hinzufügen am Ende vom Bericht, der Code hat keine Funktion :-(
///
for I := 0 to frxDBDataset1.RecordCount - 1 do
begin
DBImagefilename := frxDBDataset1.DataSet.FieldByName('newBMP').AsString;
DBType := frxDBDataset1.DataSet.FieldByName('Type').AsString;
DBObjectName := frxDBDataset1.DataSet.FieldByName('Object').AsString;
NewBand := TfrxMasterData.Create(NewDataPage);
NewBand.CreateUniqueName;
NewBand.Top := 100;
NewBand.Height := 300;
Memo_L := TfrxMemoView.Create(NewBand);
Memo_L.CreateUniqueName;
Memo_L.text := 'Hello FastReport Loop ' + IntTostr(I) + DBType ;
Memo_L.Height := 20;
Memo_L.SetBounds(10, 10, 100, 20);
if fileexists(DBImagefilename) then
begin
PictureView := TfrxPictureView.Create(NewBand);
PictureView.SetBounds(100, 100, 300, 300);
PictureView.Picture.LoadFromFile(DBImagefilename);
// PictureView.AutoSize := true;
PictureView.Stretched := true;
end
else
begin
/// to be done later
end;
end;
{ show the report }
Report.ShowReport;
Report.FileName := FileName;
Report.PrepareReport(true);
// Report.Export(TfrxPDFExport, FileName);
finally
Report.Free;
end;
end;
|
|
Zitat
|