Custom function support

Hello,

I'm planning to add reporting to my current project. Previously, it was using FR 3.0 and was wriiten in Delphi. Currently the app is being rewritten to C#. I consider using one of the three reporting engines : DevExpress XtraReports Suite, Crystal Reports and FR C# which is due to have official release (and I'm considering these options in the mentioned order)

Still however, cannot find the engine that enables me to EASILY define custom functions in source code so that the end-user can use them in the report he/she is modyfing, of course in design mode.

Such a feature is provided in FR version I use in Delphi. The ability to define several custom functions so that they can be made available to the end-user is of the greatest importance to me.

Is such a feature currently (or will be - when) if FR.NET ? I could use FR NET if only the set of features it offers is EQUAL or BIGGER the the set of features offered in older FS....

Moreover is there any manual on the site that provides some step by step instructions on how to create reports ? Currently found the demo and class documentation only.

Thank you for any response

Comments

  • edited 12:48PM
    Hello,

    You can use custom functions declared in your main app. To do this:
    - declare a function in your app; it must be "public static";
    - go report designer, "Report|Options..." menu, select "Script" and add the main app's name to the "Referenced assemblies" list;
    - now you can use the function in the report's script or in any expression (if the function returns a value).

    For example, the FR.Net Demo has the following function:
      public partial class Form1 : Form
      {
        public static void TestMessage()
        {
          MessageBox.Show("Hello from the main application!");
        }
      ...
    

    To call it from report, add "Demo.exe" to the "Referenced assemblies" and call the function from a script the following way:
        private void ReportTitle1_BeforePrint(object sender, EventArgs e)
        {
          Demo.Form1.TestMessage();
        }
    

    since this function returns nothing, you can't use it in expressions.
    Of course, you can use everything that is declared in your app, not only functions.
  • edited 12:48PM
    Regarding your qestion about documentation: it is in progress now. We hope to finish it in a month.
  • edited 12:48PM
    AlexTZ wrote: »
    Hello,

    You can use custom functions declared in your main app. To do this:
    - declare a function in your app; it must be "public static";
    - go report designer, "Report|Options..." menu, select "Script" and add the main app's name to the "Referenced assemblies" list;
    - now you can use the function in the report's script or in any expression (if the function returns a value).

    For example, the FR.Net Demo has the following function:
      public partial class Form1 : Form
      {
        public static void TestMessage()
        {
          MessageBox.Show("Hello from the main application!");
        }
      ...
    

    To call it from report, add "Demo.exe" to the "Referenced assemblies" and call the function from a script the following way:
        private void ReportTitle1_BeforePrint(object sender, EventArgs e)
        {
          Demo.Form1.TestMessage();
        }
    

    since this function returns nothing, you can't use it in expressions.
    Of course, you can use everything that is declared in your app, not only functions.


    Hello and thank you for your response.

    Does the provided solution enables me to access the data in the data layer of the report ?
    Let's say I have a dataset that is used in the reports. Then I wanna call a method that will use that data a perfor some additional calculations so that I will be able to add another textfield or label to the report presentig the results.
  • edited 12:48PM
    Hello,

    yes, for example you may declare a method in your application that will concatenate two string values:
    public static string Concat(string value1, string value2)
    {
      return value1 + " " + value2;
    }
    

    and use it in a TextObject:

    [Demo.Form1.Concat([Employees.FirstName], [Employees.LastName])]

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.