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

Template question

edited November 2012 in General
If it's not too involved, could someone explain the relationship of the
ppReport "Template" properties with the RB Designer operation? More
specifically, what does the Designer do with the Template\FileName
property, other than to use it with the LoadFromStream and LoadFromFile
methods?

If I specify only a filename with no path information, as the name of my
text-based template file, each and every time I try to open the designer
(by double-clicking the ppReport component), I get an error that the
file could not be found, and the Designer will no longer open any report
through its File/Open dialogue until I stop and restart Delphi. Where
does the Designer look, be default, for a template file to load if no
path is included with the template filename?

Unfortunately, if I allow the IDE to save a full pathname for the
template, (which is always my development path, not a deployment path)
then when the template gets loaded at runtime, the user gets another
error that the path can't be found.

Last question: if I want to manage all of the path and filename
information at runtime so that my application can guarantee that the
templates can be found in a particular folder, where in the app source
do I place code to setup the template filename and call the LoadFromFile
method? Shouldn't this ensure that my reports are using the correct
version of a template before executing?

TIA for any info and suggestions.

Comments

  • edited November 2012
    Hi Howard,

    My guess is that you have the Report.SaveAsTemplate property set to
    True. When this property is set to True, the report expects its
    definition to be inside a template file defined by the Report.Template
    properties. Otherwise the report definition is stored in the form (dfm)
    definition.

    If you are designing report templates at Delphi design-time, I suggest
    setting this property to False unless you have a valid path/file name
    defined as the Template.FileName.

    The Template.FileName property needs a full path to the location of the
    template file. If you would like this to be the application path, you
    can use something like the following before calling LoadFromFile.

    ppReport1.Template.FileName := ExtractFilePath(ParamStr(0)) +
    '\MyTemplate.rtm';
    ppReport1.Template.LoadFromFile;

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2012
    Thanks very much for the response, Nico.

  • edited November 2012
    Hi Howard,

    At Delphi design-time, if SaveAsTemplate is True, the report only saves
    and loads the report definition from the defined template file. If
    SaveAsTemplate is False, the report definition is saved and loaded from
    the form definition. It is possible to manually save this report to a
    template file at this point but not necessary.

    Again, if you are designing multiple reports at Delphi design-time, the
    best option is to set SaveAsTemplate to False, and manually load and
    save each template file as you need.


    We will consider this for a later release. Currently you will need to
    handle this yourself in code.


    Yes, set SaveAsTemplate to False. The designer needs a report
    definition to load. Setting SaveAsTemplate to False will load the
    report definition stored in the form or create a new blank one. From
    there you can load/save any templates you need.


    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2012
    Thanks again, Nico,

    Given the information you've provided, I think I'm slowly but surely
    figuring out some different ways to approach my template issues.

    I will, however, put another vote in for RB allowing '.\ppReport' as a
    valid path name for the purposes of locating a template file,
    particularly during design. I think there's maybe more than one
    situation where this would just make the template file management thing
    a little less tricky.

    Regards,
    Howard


This discussion has been closed.