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

Load report

edited February 2003 in End User
Hi,

Is it possible to open a report (print, preview) in an end user application
by code.

Example of my code :

if Preview then
myEndUserSolution.ppReportExplorer1.PrintPreview(ReportName,FolderId)
else
myEndUserSolution.ppReportExplorer1.Print(ReportName,FolderId);

but the report isn't print.

Thank's

Comments

  • edited February 2003
    I tested your issue on my machine using RBuilder 7.01 with Delphi 7 and
    found no problem. I used the (RBuilder\Demos\3. EndUser\2. Custom Data

    Views\) demo and created a radio button group with one option to print and
    the other option to print preview. The code in the btnLaunchClick

    event was changed to the following:

    procedure TmyEndUserSolution.btnLaunchClick(Sender: TObject);
    begin

    {The 'Print Preview' radio button is checked}
    if (rbPreview.Checked) then

    myEndUserSolution.ppReportExplorer1.PrintPreview('Customer List', 1)

    {The 'Print' radio button is checked}
    else

    myEndUserSolution.ppReportExplorer1.Print('Customer List', 1);

    end;

    This seemed to function correctly. If you still have problems, please
    provide a more detailed way to reproduce this problem.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited February 2003
    I want to print my report from an another program(xxx.exe)
    The xxx.exe send a command line to my program with the report name and the
    folder id and preview or print.
    And in my program i execute this code when i receive this commande line :

    myEndUserSolution.ppReportExplorer1.PrintPreview(ReportName,FolderId)

    but the report not print.

    what's the problem please?

    thank's

    "Nico Cizik (Digital Metaphors)" a ?crit dans
  • edited February 2003
    1. The first test would be to get it working within the same program as I
    did in my example.

    2. The standard way to control one application from another is via COM.
    There are some books on using COM with Delphi that can help you with this.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited February 2003
    When I launch my application from another,
    I don't execute the ppReportExplorer.Execute and the ppReportExplorer.form
    is nil.

    How do I assigned the ppReportExplorer.Form?

    thank's


    "Nico Cizik (Digital Metaphors)" a ?crit dans
  • edited February 2003
    Below is an article explaining how to load a report without showing the
    Report Explorer form. You can then use Report.Print.

    ---------------------------------------------------------------
    Tech Tip: How to Programmatically Load Reports that were Saved
    using the Report Explorer
    ---------------------------------------------------------------

    1. The ReportExplorer has a run-time interface you can use to load reports
    using the ReportExplorer.LoadReport method. You can use this method without
    actually 'showing' the report explorer form. (See the online help topic for
    TppReportExplorer.)

    2. If you want use Report.Template.LoadFromDatabase, RB will locate the
    report stored in the database table based upon the NameField value only.
    However, for the rb_item table you need Folder_Id, Name to locate a record
    uniquely.

    To override this default behavior, assign an event-handler to the
    Report.Template.OnLocateRecord event.

    example:

    TmyForm = class(TForm)
    private
    function ReportLocateRecordEvent(Sender: TObject; const aReportName:
    String): Boolean;

    end;

    procedure TmyForm.FormCreate(Sender, TObject);
    begin
    {assign the event handler}
    FReport.Template.OnLocateRecord := ReportLocateRecordEvent;

    end;


    function TmyForm.ReportLocateRecordEvent(Sender: TObject; const aReportName:
    String): Boolean;
    begin
    {add logic here to locate the record and return True if it is found}

    Result := myLocateReportFunction(FFolderid, aReportname);

    end;

    --
    Best Regards,

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