A flexreport or a .flxr file is divided into sections. These sections can be viewed in the report when you open it in the FlexReportDesigner app. Every report consists of basic sections such as, Report Header, Page Header, Group Header, Detail, Group Footer, Page Footer, Report Footer and Sub-section. The report sections help in partitioning the report vertically. Based on their type (for example, Page, Group, Sub-Section etc.), they are arranged, by default, at specific places within the report.
The following diagram shows how each section is rendered on a typical report. It also displays how a sub-section in the Detail section is rendered in the report:
To create user-friendly reports, you need to understand how each section works. Let us explore each section in the order they appear in the report.
Sub-sections are the additional sections that can be added to any section of a report. A FlexReport generally contains - Detail, Header, Footer, PageHeader, Page Footer, Group Header and Group Footer. You can add as many sub-sections as required in a section. This can be done via the FlexReportDesigner application or through code.
Sub-Sections can be added to any section of a report. By default, the sub-section gets added at the bottom of the currently selected section.
For instance, let's say you want to add a sub-section in the Page Header. This can be easily achieved via the FlexReportDesigner as well as through code:
Since creating reports is all about representing data, it is important to determine the sub-section behavior when its too large to fit within the vertical space available on the current page.
In FlexReports, any Section or Sub-section can be forced to split or not to split (keep together) between the pages by setting SplitBehavior property to SplitIfNeeded or KeepTogether.
The KeepTogether option lets the object to be split only if it is too large to fit on an empty page. If that's the case, then the object is split immediately. Otherwise, a new page is started and the object is placed on it without splitting. While, the SplitIfNeeded option lets the object to be split if it does not fit onto the current page.
Similarly, the splitting of Fields and Borders is governed by SplitHorzBehavior and SplitVertBehavior properties. The SplitHorzBehavior property determines how the borders are drawn for an object if it is too wide and split between pages. On the other hand, the SplitVertBehavior property determines how the borders are drawn for an object if it is too high and split between pages.
The following code sets the SplitBehavior for a Section and a Sub-section:
C# |
Copy Code
|
---|---|
// Allow section to split if needed c1FlexReport1.Sections.Header.SplitBehavior = SplitBehavior.SplitIfNeeded; // Allow sub-section to split if needed c1FlexReport1.Sections.Header.SubSections[0].SplitBehavior = SplitBehavior.SplitIfNeeded; |
You can determine whether or not a section is visible by setting its Visible property to True or False. Group Headers can be repeated at the top of every page (whether or not it is the beginning of a group) by setting their Repeat property to True. Page Headers and Footers can be removed from pages that contain the Report Header and Footer sections by setting the PageHeader and PageFooter properties on the Layout object.