Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Cover Page via Title Band and common Footer Band

edited May 2003 in General
I don't know if this is possible but here goes...

We tried creating a report with a Title band and Footer band. Every other
report has empty Title and Footer bands. From these other reports we need to
be able to assign the Title and Footer from this common report. Since we
will have hundreds of reports in our final product, we need a common Cover
page (i.e. Title Band) and Footer to prevent having to change every report
if the Cover Page or Footer changes. So far we have had no luck.

Has anyone else been able to get this to work? Is there a better way of
handling this? We don't use templates and even if we did wouldn't the rest
of each report have to be created in code if we did?

Mark Greenhaw
OneDomain, Inc.
xmark@onedomain.comx
(remove the x's to reply via email)

Comments

  • edited May 2003
    Mark,

    Check out the installed dynamic subreport loading demos in the
    \RBuilder\Demos\3. EndUser\5. Dynamic Subreport Loading... directory.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited May 2003
    I have been unable to find the example you are referring to but I thought
    Jim Bennett said this particular solution utilizes template files. Do yo
    have a location I can download this example from and does it require the use
    of template files?

    Thanks,
    Mark Greenhaw
    OneDomain, Inc.
    xmark@onedomain.comx
    (remove the x's to reply via email)

  • edited May 2003
    Below you find a small unit which does what you want. Us it in your
    application and at report-design you will find a new subreport-componet.
    Instead of designing the subreport itself, enter the name of an existing
    report in the label-caption field. When the main report is generated, this
    component will load the named subreport.

    HTH
    Bernd

    { **************************************************
    Unit name : E:\Delphi Projekte\Libraries\Baf\ReportEngine\SubReportBAF.pas
    Created : 05.04.2001 18:32:52
    By : MAB (c) dato Denkwerzeuge
    Purpose : TbafSubreport enth?lkt einen Templatenamen
    Zur Laufzeit wird dieses Template geladen
    und gedruckt --> Standard Headers etc.

    $History : $

    *************************************************** }
    unit SubreportSOF;

    interface

    uses
    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
    IniFiles, ppClass, ppBands, ppSubRpt,
    ppTypes, ppVar, ppCtrls;

    type
    TBafSubReport = class(TppSubReport)
    private
    FAutomatedLoad : Boolean;
    FTemplateName : String;
    procedure LoadSubreport;
    protected
    function GetTemplateName : string;
    procedure SetTemplateName(Value: string);
    function GetCaption : string; override;
    public
    constructor Create(aOwner: TComponent); override;
    destructor Destroy; override;
    procedure Generate; override;
    procedure StartOfMainReport; override;
    published
    property AutomatedLoad : Boolean read FAutomatedLoad write
    FAutomatedLoad default True;
    property TemplateName : string read GetTemplateName write
    SetTemplateName;
    end;

    implementation

    {$R SubreportSOF.res}

    // -- Create
    constructor TBafSubReport.Create(aOwner: TComponent);
    begin
    inherited Create(aOwner);
    FAutomatedLoad:=True;
    DefaultPropName:='TemplateName';
    DefaultPropEditType:=etEdit;
    end;

    // -- Destroy
    destructor TBafSubReport.Destroy;
    begin
    inherited Destroy;
    end;

    // -- Generate
    procedure TBafSubReport.Generate;
    begin
    Report.AutoStop:=True;
    inherited Generate;
    end;

    // -- LoadSubreport
    procedure TBafSubReport.LoadSubreport;
    begin

    Report.Template.FileName:=ExtractFileDir(Report.MainReport.Template.FileName
    )+'\'+FTemplateName;
    Report.Template.LoadFromFile;

    Report.PrinterSetup.DocumentName:=Band.Report.MainReport.PrinterSetup.Docume
    ntName;
    Report.Engine.State := Report.Engine.State - [esInitialized];
    Init;
    end;

    // -- StartOfMainReport
    procedure TBafSubReport.StartOfMainReport;
    begin
    inherited StartOfMainReport;
    if (AutomatedLoad) and not (Overflow) then begin
    LoadSubreport
    end;
    end;

    // -- SetTemplateName
    procedure TBafSubReport.SetTemplateName(Value: string);
    begin
    if FTemplateName<>Value then begin
    FTemplateName:=Value
    end;
    end;

    // -- GetTemplateName
    function TBafSubReport.GetTemplateName : string;
    begin
    Result:=FTemplateName;
    end;

    // -- GetCaption
    function TBafSubReport.GetCaption : string;
    begin
    Result:='Runtime template';
    end;

    initialization
    ppRegisterComponent(TBafSubReport, 'Demo Components', 0, 0, 'Runtime
    template', 0);

    finalization
    ppUnRegisterComponent(TBafSubReport);

    end.
  • edited May 2003
    Thanks Bernd, Here is another similar example if you need.

    http://www.digital-metaphors.com/tips/DynamicallyLoadedSubreportForHeader.zip

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.