Styles are a set of properties that you can apply to selected controls in your Page or RDL reports to quickly change their appearance. A single style can define properties for font, background color, line spacing, border color, padding, and many more. You can create four different types of styles, namely Common, Text, Table Of Contents and Table Of Contents Level. For more information on the type of styles and how they differ from each other, see Working with Styles.
ActiveReports provides you with the ability to create multiple styles and store them in a style sheet. A style sheet can be understood as a collection of styles. You can add the style sheet to your Page or RDL reports using the GrapeCity.ActiveReports.PageReportModel.Report.StyleSheetSource and GrapeCity.ActiveReports.PageReportModel.Report.StyleSheetValue properties and apply the styles to selected controls using the GrapeCity.ActiveReports.PageReportModel.Style.StyleName property. You can either embed the style sheet within your report or save it externally in the *.rdlx-styles format. For more information, see Working with Styles.
There are two ways to use these style sheets:
Using styles gives you more control over how you format the report. Let us look at a few scenarios to understand how styles are helpful while designing reports.
Reusing Styles
An organization wants to create an Annual Sales Report that consists of multiple subreports, representing Sales by District and Sales by Product. Since all the subreports are a part of the Annual Sales Report, the formatting needs to be consistent. You normally have to manually set properties for each control on the report to format it and then replicate those same set of properties for the two subreports. This can be time consuming and can lead to inconsistent styling in your reports. Let us see how the ActiveReports Style feature can help you generate consistent styles in all reports similar to the screenshot below.
Report author can create a style sheet for designing the Annual Sales Report (main report), add styles to the style sheet using the Stylesheet Editor dialog. After creating the styles, these styles can be applied to various controls on Annual Sales Report using the GrapeCity.ActiveReports.PageReportModel.Style.StyleName property. For more information, see Working with Styles.
Once the Annual Sales Report has been designed, the GrapeCity.ActiveReports.PageReportModel.Subreport.InheritStyleSheet property can be set to True (by default) for each subreport.
By setting the InheritStyleSheet property to True, the style sheet used for the Annual Sales Report is automatically inherited in the subreports. This makes all the styles in the style sheet available to the two subreports. To apply the styles to the report controls in a subreport, you simply need to select the report control and specify the name of the style you want to use in the StyleName property.
In this example we can see how styles can help save time and maintain consistent formatting by giving you the flexibility to use the same style sheet in multiple subreports.
You can also use the same style sheet in multiple reports by saving the style sheets externally in *.rdlx-styles format. For more information on how to work with external style sheets, see Working with Styles.
In ActiveReports, you can embed external style sheets in a report. This is particularly useful when you want to send reports that are styled using multiple style sheets. Let us take an example of a Sales Report to see how embedded style sheets can help improve the report portability.
Scenario
An organization wants to send a Sales report that is styled using 4 different external style sheets. While sending the styled report, 5 files have to be sent together, i.e. one report and 4 external style sheets. The person receiving these files needs to maintain and store 5 different files. Moreover, if the location of a style sheet is changed from the path set in the report, the style sheet will no longer be applied to the report until the path is modified in the report.
By embedding the external style sheets within the Sales report, only 1 file needs to be sent which in turn improves the portability of the report. For more information on how to embed external style sheets, see Embed External style sheet into a report