As you probably know, reports in FastReport.Net can be created not only in a special designer, but also from the code of the user application. At the same time, instead of the usual file with frx extension, you will get a class of report. It can be converted into a library and used in different projects. What is this way of creating such report?
Take a look at this code:
This is an example of creating a report template with groups. As you can see, we are consistently creating report objects, starting with the report and pages to text objects. We put the created objects into the other and configure the properties of their display. This requires a good performance FastReport.Net report template structure. In addition to this, to achieve the desired arrangement of the elements, you'll have plenty of time to run a report for the visual evaluation and to correct the properties of objects, exhibiting the desired width or coordinates. Therefore, this approach should be to report on lists, matrices, tables - where there is no need to adjust the location of the elements relative to each other.
The main advantage of a report generated in the code is the ability to edit reports during execution, adding code depending on conditions or events. This allows you to create reports with complex logic that directly depends on the client application itself.
It is no secret that FastReport.Net report templates are xml-like format, despite the extension frx. These templates are easy to transfer and view on other computers via Viewer program. Mobility and independence from the client application - it is undeniable advantages of the traditional pattern in frx report format, or a version with data filled in fpx format. Therefore, having in your application reports generated from the code, many would like to be able to convert them to normal xml-like format frx. It incredibly simple to do so:
That is, you just need to use the “Save” function in the report object. As the parameters are passed to the path to the file name in which to save the report. So we can use a single account that is created from the code, and, if necessary, to convert it into a traditional format frx. The resulting file can be transferred to other developers or users.
Both code-based reports and frx reports have their advantages. The first is that it wins when the report needs to be changed directly "on the go," the second is when a mobile report is required, or the template has many elements with a clearly defined location relative to each other. You need to choose a way to create a report based on these benefits.