Wrap report file into exe file? Generate report via code?

Hey there.

I know there is documentation for "Creating a report form from code" (section 1.12 in Programmer Manual), however it's very unclear and diluted. I realize FR is originally a German company, and as such there are a few things that get lost in translation in the manual. I cannot find a real world example ANYWHERE for designing a report via code. If anyone has one that'd be great.

The reason I ask about designing a report via code is because my company needs to distribute an .exe file. I have been looking around for days (if not weeks) about how to bundle or wrap an .fr3 (or .fp3) file into the executable. I have looked into .res files (doesn't work unless I'm missing something), and I have looked into .dll files. Neither of which solve my issue. I've heard tell of .reg files, but I haven't been able to find anything on this. The reports will be passed parameters at run time and displayed accordingly.

So that leaves me to ask the FR community.
- Have you successfully bundled an FR report into an .exe file? If so, how?
- Are there any examples of generating a report through code?


Any help/tips/examples are welcome. Thanks in advance!

Comments

  • edited 7:58AM
    frxReport.StoreInDFM := TRUE;
  • gpigpi
    edited 7:58AM
    Also you can store several report templates in resources and use one instance of TfrxReport
    unit MainUnit;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, ImgList, frxDesgn, frxClass;
    
    type
      TFormMain = class(TForm)
        Button1: TButton;
        OpenDialog: TOpenDialog;
        frxReport1: TfrxReport;
        frxDesigner1: TfrxDesigner;
        Button2: TButton;
        Edit1: TEdit;
        frxReportMain: TfrxReport;
        procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
      private
        { Private declarations }
         procedure LoadRptFromResource(Report: TfrxComponent; const ResName: string);
      public
        { Public declarations }
      end;
    
    var
      FormMain: TFormMain;
    
    implementation
    
    uses PreviewFormUnit;
    
    {$R *.dfm}
    
    //**********************************************//
    procedure TFormMain.LoadRptFromResource(Report: TfrxComponent;
               const ResName: string);
    var
      m: TResourceStream;
    begin
      m := TResourceStream.Create(HInstance, ResName, RT_RCDATA);
      try
        m.Position := 0;
        Report.LoadFromStream(m);
      finally
        m.Free;
      end;
    end;
    //****************************************************************************//
    
    
    procedure TFormMain.Button1Click(Sender: TObject);
    var
    Report: TfrxReport;
    begin
    
     Report:= frxReportMain;
     Report.Preview := nil;
    
     Report.Script.Variables['dDAT'] := Edit1.Text;
    
     //Report.LoadFromFile( ExtractFilePath(Application.ExeName) + 'ReportList\Test.fr3 ');
     // 
     LoadRptFromResource(Report, 'Test'); // 
     Report.PrepareReport(True);
    
     //Report.LoadFromFile( ExtractFilePath(Application.ExeName) + 'ReportList\Test2.fr3 ');
     //
     LoadRptFromResource(Report, 'Test2'); // 
     Report.PrepareReport(False);
    
     Report.Preview:= PreviewForm.frxPreviewMain;
     PreviewForm.ShowModal;
    end;
    
    procedure TFormMain.Button2Click(Sender: TObject);
    begin
     frxReport1.DesignReport;
    end;
    
    end.
    
  • edited 7:58AM
    Thank you so much for your fast responses. I'll look into these immediately! >
  • gpigpi
    edited 7:58AM
    See a demo project in attach

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.