Recent

Author Topic: LazReport : How to use TfrCompositeReport ?  (Read 3958 times)

Pabdym

  • New Member
  • *
  • Posts: 21
LazReport : How to use TfrCompositeReport ?
« on: September 26, 2012, 05:52:50 pm »
Hi,

Code: [Select]
for i := 1 to 36 do begin
   sgEL.Row := i;
   frReport1.LoadFromFile(gsReportPath+myReport.lrf');
   frReport1.PrepareReport;  {from Rows[i]}
   frCompositeReport1.Reports.add(frReport1);
end;
frCompositeReport1.ShowReport;

frCompositeReport1 contains 36  pages but the same (the last one). How is it necessary to proceed?
                                   
Thanks
« Last Edit: September 26, 2012, 06:48:14 pm by Pabdym »
Laz 1.1-38979 fpc-2.6.1-20121007-win32
Laz 1.0.4-0_amd64  fpc_2.6.0-120824_amd64 (x86_64-linux-gtk2)  [2013-01-02]

jesusr

  • Sr. Member
  • ****
  • Posts: 470
Re: LazReport : How to use TfrCompositeReport ?
« Reply #1 on: September 26, 2012, 10:58:14 pm »
It looks like it has 36 copies of the same report.

try

Code: [Select]
var
  r: TfrReport;
for i := 1 to 36 do begin
   sgEL.Row := i;
   r:=TfrReport.create(self);
   r.loadFromFile(gsReportPath+'myReport.lrf'); // here myReport.lrf must be the report corresponding to Row "i"
   frCompositeReport1.Reports.add(r);
end;
frCompositeReport1.ShowReport;

Just like is demostrated in the lazarus/components/lazreport/samples/editor sample project.

Pabdym

  • New Member
  • *
  • Posts: 21
Re: LazReport : How to use TfrCompositeReport ?
« Reply #2 on: September 27, 2012, 12:54:12 pm »
I tried your code : 36 empty pages.

Thus, I tried :
Code: [Select]
type
TForm1 = class(TForm)     
 Filas: TfrUserDataset;   
 frCompositeReport1: TfrCompositeReport;       
 [...]
 procedure TheReportEnterRect(Memo: TStringList; View: TfrView);
 procedure TheReportGetValue(const ParName: String; var ParValue: Variant);
 [...]
end;

procedure TForm1.Button12Click(Sender: TObject);
var
i : integer;
begin

  with frCompositeReport1 do begin
    DoublePass:= True;
    Reports.Clear;
  end;
  for i := 1 to 36 do begin
   sgEL.Row := i;
   TheReport :=TfrReport.Create(self);
   TheRepor.OnEnterRect:= @TheReportEnterRect;
   TheReport.OnGetValue:= @TheReportGetValue;
   TheReport.Dataset := Filas;
   TheReport.loadFromFile(gsReportPath+'myReport.lrf');
   //TheReport.PrepareReport;
   //TheReport.ShowReport; {The 36 pages are OK}
   frCompositeReport1.Reports.add(TheReport);
end;
frCompositeReport1.ShowReport;

It always looks like it has 36 copies of the same report (the last page). With ' TheReport.PrepareReport + TheReport.ShowReport ', each of the reports 'TheReport' is correct.

I also tried :
Code: [Select]
var  TheReport : array [1..100] of TfrReport;
begin
for i := 1 to 36 do begin
   sgEL.Row := i;
   TheReport[i]:=TfrReport.Create(self);
   TheReport[i].OnEnterRect:= @TheReportEnterRect;
   TheReport[i].OnGetValue:= @TheReportGetValue;
   TheReport[i].Dataset := Filas;
   TheReport[i].loadFromFile(gsReportPath+'myReport.lrf');
 //  TheReport[i].PrepareReport;
 //  TheReport[i].ShowReport;         {It's OK}
   frCompositeReport1.Reports.add(TheReport[i]);
   TheReport[i].Free;
end;
frCompositeReport1.ShowReport;
   

After the last " TheReport(i).Free;" --> Exception class 'External : SIGSEGV'.

Without 'TheReport(i).Free;', the result is the same: 36 identical pages (the last one). With ' TheReport(i).PrepareReport + TheReport(i).ShowReport ',  each of the reports 'TheReport(i)' is also correct.


« Last Edit: September 28, 2012, 09:57:53 am by Pabdym »
Laz 1.1-38979 fpc-2.6.1-20121007-win32
Laz 1.0.4-0_amd64  fpc_2.6.0-120824_amd64 (x86_64-linux-gtk2)  [2013-01-02]