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

Setting TextFileName

edited July 2006 in General
I am trying to set the value of the TextFileName from TppReport by pogram.
But it does not work as expected.
My wishes are to set the name depending by the filetype. So if I select Text
then I want a filename like XXX.txt and if I select Excel then XXX.xls

Is this possible?

All of this is running wth Delphi 5 and RB 7.0.3

Thanks for any information

Regards
Nicolas

Comments

  • edited July 2006
    Hi Nicolas,

    Each device should define the file extension automatically. For instance,
    if you are exporting to PDF and you set the TextFileName property to
    "MyReport", the PDF device will automatically add the .pdf extension to the
    file (MyReport.pdf). In my quick testing on my machine, this worked
    correctly.

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited July 2006
    Thank you for your answer. Now I found out, that the TextFileName is stored
    in the RTM file (and in our case inside of oracle).
    Although I made a change in the datamodule ppReport.TextFileName :=
    'MyReport'; I get everytime the value from the RTM file after I change the
    Filetype

    Is this a bug?

    Regards
    Nicolas
  • edited July 2006
    Hi Nicolas,

    This is not a bug, you will need to either re-save your templates with the
    changed TextFileName or re-assign it in the OnLoadEnd event of the template
    object. See the article below for more information.

    ----------------------------------------------
    Tech Tip: Using Template Events
    ----------------------------------------------

    The Report.Template object has several events that can be used for
    customizing what happens when a report is loaded or saved:

    - OnLoadStart
    - OnLoadEnd
    - OnNew
    - OnSaveStart
    - OnSaveEnd


    The OnLoadEnd and OnNew events are often used to perform actions related
    to report and data initialization.

    The OnSaveEnd event is often used to save additional descriptive
    ("meta") data to the database each time the report is saved.

    Example:

    The Report.Template events are public and therefore must be assigned at
    run-time.


    1. In the private section of your form declaration you can declare an
    event-handler method:

    TForm = class(TForm)
    private
    procedure myTemplateOnLoadEndEvent(Sender: TObject);

    public

    end;


    2. In the Form.OnCreate event, you can assign the event-handler to the
    event:

    procedure TForm1.FormCreate(Sender: TObject);
    begin

    ppReport1.Template.OnLoadEnd := myTemplateOnLoadEndEvent;

    end;


    3. Implement the event-handler method:

    procedure TForm1.myTemplateOnLoadEndEvent(Sender: TObject);
    begin

    {add code here to initial the report or data, etc. }
    ppReport1.PrinterSetup.MarginTop := 0.5;

    end;


    --
    Regards,

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

    Best Regards,

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