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

report template as text

edited October 2007 in General
I like to get the reporttemplate as text so I can save it as text via
our own class(assigning to it's text property).

The correct place to do this is the Customdocsave event of the designer,
right?

After that I also need a way to convert the text back to a template
what would be the best approach?

We are using report builder 10.07 with Delphi 2005

Luc Neville
DMS software products



--- posted by geoForum on http://delphi.newswhat.com

Comments

  • edited October 2007
    Hi Luc,

    Templates can be saved and loaded as ASCII text with ReportBuilder, there is
    no need to convert them back and forth. Simply set the
    Report.Template.Format property to ftASCII and the template will be saved to
    text. This template can later be loaded by ReportBuilder as is.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited October 2007
    Nico
    I know it's possible to save a template as a file but I don't want to
    save it into a file I just want the template represented as text
    assigned to a string property of our own class.

    Saving it to a file, then opening it up and assign the text to the
    property of our own designed class seems to me like unnescessary
    read/write actions. I'd like to assign it directly without
    reading/writing to file but I don't know if reportbuilder has this
    option.

    Luc Neville
    DMS Software Products



    --- posted by geoForum on http://delphi.newswhat.com
  • edited October 2007
    Hi Luc,

    Sorry, I was not clear that it is not necessary to save a template to file.
    A template can be saved to a memory stream as well, then loaded into an
    object such as a TStringList. Something like the following...

    var
    lMemoryStream: TMemoryStream;
    lStringList: TStringList;
    begin

    lMemoryStream := TMemoryStream.Create;
    lStringList := TStringList.Create;

    try

    ppReport1.Template.Format := ftASCII;
    ppReport1.Template.SaveToStream(lMemoryStream);

    lMemoryStream.Position := 0;

    lStringList.LoadFromStream(lMemoryStream);

    ShowMessage(lStringList.Text);

    finally
    lStringList.Free;
    lMemoryStream.Free;
    end;

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited October 2007
    thank you very much Nico

    Maybe because I never use streams I didn't figure this out myself.



    --- posted by geoForum on http://delphi.newswhat.com
This discussion has been closed.