Reporting

Styles created in a report can be exported and then used in other reports. You can store one or more Styles in an exported file. The exported information is stored in an XML file.

Export a Style Sheet

  1. Open the report in design view.
  2. Select the Report object.
  3. Click in the StyleSheet property, and then click the ellipsis button to open the StyleRule Collection Editor.
  4. Select one or more of the styles in the Members box on the left. Use Windows keyboard combinations to select more than one style.

  5. Click the Export button. This will open the Save As dialog box.
  6. Enter a name for the exported file and click Save to complete the task.

Use an Exported Style Sheet in Another Report

  1. Open the report in design view.
  2. Select the Report object.
  3. Click in the External Styles property, and then click the ellipsis button to open the Collection Editor.
  4. Click the Add icon in the upper left corner of the Collection Editor window. This will open a File Open dialog. You will be located in the current project's root directory.
  5. Browse to, and then select, the exported Style Sheet. Click Open. This action will return you to the Collection Editor window.
  6. When you are finished adding Style Sheets, click OK.

Styles that are defined by TypeSelectors or AttributeSelectors will be automatically formatted. To use styles defined by StyleSelectors, change the StyleName property of the desired report item to the appropriate style names that exist in the Style Sheets that you added.

External Style Sheet Location Kinds

There are three ways in which an external style sheet can be located:

  • Absolute Path/URL such as C:\Application1\StyleSheets\StyleSheet1.xml or
  • Relative Path/URL such as .\StyleSheets\StyleSheet1.xml or ~/StyleSheets/StyleSheet1.xml
  • Resource Name such as Application1.Resources.StyleSheet1.xml

When you add a new external style sheet to the collection it will be recorded via Relative or Absolute path depending on the file's location. If the file that you chose is located inside the current project root directory the style sheet will be recorded via relative path, otherwise it will be recorded via absolute path. Later you can change the way it is serialized by changing its location kind from the combo box next to its name.

Absolute Path/URL

The external style sheet file does not have to be a part of the project since it is referenced absolutely.

Relative Path/URL

When an external style sheet is referenced relatively the path is relative to the hosting application root folder. The project item representing the style sheet file should have its "Copy to Output Directory"="Copy Always". When you use the Collection Editor, a project item for the style sheet file will be created automatically, if it does not exists, and it will be moved to a folder named "StyleSheets" under the project root and its "Copy to Output Directory" property will be adjusted automatically as well.

Note

For Windows Forms projects, the root folder is the location of the executable file (by default bin folder). In Web applications the root folder is the root of the application. In this case the stylesheets should be copied to the root of the Web application as well.

Resource Name

You can reference an external style sheet as an embedded resource by its name. The name should be the case-sensitive name of the manifest resource being requested. The project item representing the style sheet file should have its "Build Action"="Embedded Resource". When you use the Collection Editor, a project item for the style sheet file will be created automatically, if it does not exists, it will be moved to a folder named "Resources" under the project root and its "Build Action" property will be adjusted automatically as well. In the end the generated name will look something like MyApplication1.Resources.StyleSheet1.xml, where MyApplication1 is the default project  namespace and the file is located in the folder Resources.

Note

Specifying an URL for the external style sheet can be done only programmatically. It is not supported directly from the Collection Editor.