Place ReportSummary at the bottom in Run Time

Ok, I have a ReportSummary that needs to be at the bottom at the last page. I know if I use OnBeforePrint in the designer I can do it like this:
procedure ReportSummary1OnBeforePrint(Sender: TfrxComponent);
begin
Engine.CurY := Engine.CurY + Engine.FreeSpace - ReportSummary1.Height - 1;
end;

The problem is that I don't use the designer. Everything in my report is created in run time like this:

    frxReport:= TfrxReport.Create(Owner);
    ....
    Page:= TfrxReportPage.Create(frxReport);
    Page.CreateUniqueName;
    Page.SetDefaults;
    Page.Orientation:= poLandscape;
    ....
    ReportSummary:= TfrxReportSummary.Create(Page);
    ReportSummary.CreateUniqueName;
    ReportSummary.Top:= 0;
    ReportSummary.Height:= 50;



I tried this:

    frxreport.ScriptText.Add('procedure ReportSummary1OnBeforePrint(Sender: TfrxComponent);');
    frxreport.ScriptText.Add('Begin');
    frxreport.ScriptText.Add('Engine.CurY := Engine.CurY + Engine.FreeSpace - ReportSummary1.Height - 1;');
    frxreport.ScriptText.Add('end;');


But this did not help. Any idea how I can move Reoirt Summary in run time?

Comments

  • gpigpi
    edited 1:21PM
    1. You should add your script at the begin of frxreport.ScriptText
    2. Add
    ReportSummary.OnBeforePrint := 'ReportSummary1OnBeforePrint';
    to your Delphi's code
  • edited 1:21PM
    Point 2 is clear, thank you.

    Can you help me with point 1? How can I add my script at the begin of frxreport.ScriptText? I am not writing anything else in frxreport.ScriptText, isn't it at the beginning already?
  • gpigpi
    edited 1:21PM
    frxreport.ScriptText.Insert(0, 'end;');
    frxreport.ScriptText.Insert(0, 'Engine.CurY := Engine.CurY + Engine.FreeSpace - ReportSummary1.Height - 1;');
    frxreport.ScriptText.Insert(0, 'Begin');
    frxreport.ScriptText.Insert(0, 'procedure ReportSummary1OnBeforePrint(Sender: TfrxComponent);');
    
  • edited 1:21PM
    Well, thanks. It does make changes to the report but it messes everything up. Pagefooter dissapered, etc. Now I need to figure out what is going on. Is it possible Engine.CurY and / or Engine.FreeSpace to have wrong values?
  • gpigpi
    edited 1:21PM
    Attach your report template (fr3). Use TfrxReport.SaveToFile
    Also set correct Top position for all bands
  • edited 1:21PM
    It looks like that the problem is comming from the PageFooter (that is set not to print in the last page). Without it everything is fine. It is quite big, when there are data only for one page, PageFooter do not show (as it is supposed not to show) but it still takes space and ReportSummary is printed above that empty space and into the DataBand.
  • gpigpi
    edited 1:21PM
    Use
    Engine.CurY := Engine.CurY + Engine.FreeSpace + PageFooter1.Height - ReportSummary1.Height - 1;
    
  • edited 1:21PM
    Thank you very much, I was going to try this myself and it will probably solve the problem. Unfortunately that does not matter now as I just learned that the layout was different from the start...

    Anyway, thank you!
  • cikacika Deutschland
    edited 1:21PM
    Hallo,

    habe das gleiche Problem, das Summary-Band soll immer am Seitenende angezeigt werden, mit der Anweisung
    Engine.CurY := Engine.CurY + Engine.FreeSpace - ReportSummary1.Height - 1;
    wird der Report, je nach Zeilenanzahl, wie folgt angezeigt.
    report_beispiel.jpg
  • gpigpi
    edited March 2017
    cika
    Attach your report template (fr3) and prepared report (fp3)
    Did you don't show PageFooter on the last page too?

    Use English
    if Engine.FreeSpace + PageFooter1.Height < ReportSummary1.Height then Engine.NewPage;
    Engine.CurY := Engine.CurY + Engine.FreeSpace + PageFooter1.Height - ReportSummary1.Height - 1;
    
  • cikacika Deutschland
    edited 1:21PM
    gpi wrote: »
    cika
    Attach your report template (fr3) and prepared report (fp3)
    Did you don't show PageFooter on the last page too?

    Use English
    if Engine.FreeSpace + PageFooter1.Height < ReportSummary1.Height then Engine.NewPage;
    Engine.CurY := Engine.CurY + Engine.FreeSpace + PageFooter1.Height - ReportSummary1.Height - 1;
    

    Hello,

    Here the sample report.

    Many Thanks

    Georg Steinbrecher
  • gpigpi
    edited 1:21PM
    If you use page footer on the all pages - use
    if Engine.FreeSpace < ReportSummary1.Height then Engine.NewPage;
    Engine.CurY := Engine.CurY + Engine.FreeSpace - ReportSummary1.Height - 0.00001;
    
  • cikacika Deutschland
    edited 1:21PM
    gpi wrote: »
    If you use page footer on the all pages - use
    if Engine.FreeSpace < ReportSummary1.Height then Engine.NewPage;
    Engine.CurY := Engine.CurY + Engine.FreeSpace - ReportSummary1.Height - 0.00001;
    


    Thanks for the good support ....

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.