|
|
       
Telerik Reporting settings are defined in a custom configuration section called Telerik.Reporting. In order to process the configuration file correctly the .NET Framework requires this section to be the first child element in the <configuration> element, like this:
CopyXML <configuration>
<configSections>
<section
name="Telerik.Reporting"
type="Telerik.Reporting.Processing.Config.ReportingConfigurationSection, Telerik.Reporting, Version=x.x.x.x, Culture=neutral, PublicKeyToken=a9d7983dfcc261be"
allowLocation="true"
allowDefinition="Everywhere"/>
</configSections>
…
</configuration>
<Telerik.Reporting> Configuration Section
CopyXML <Telerik.Reporting>
<Extensions>
<Render>
<Extension>
<Parameters>
<Parameter/>
</Parameters>
</Extension>
</Render>
</Extensions>
<SessionState>
<Providers>
<Provider>
<Parameters>
<Parameter/>
</Parameters>
</Provider>
</Providers>
</SessionState>
</Telerik.Reporting>
<Telerik.Reporting> element
Telerik.Reporting XML element is the root element of the Telerik Reporting engine settings. All the settings of the Reporting engine are nested in it.
| Attributes |
No attributes are defined for this element |
| Child elements |
Extensions – Specifies a collection of extensions, for which the configuration is applied |
| Parent element |
Configuration - Specifies the required root element in every configuration file that is used by the common language runtime and
the .NET Framework applications. Only one Telerik.Reporting element can be used in the Configuration element. |
<Extensions> element
Extensions XML element specifies a collection of extension types, for which configuration is applied.
| Attributes |
No attributes are defined for this element |
| Child elements |
Render – specifies a collection of render extensions, for which the configuration settings are applied. |
| Parent element |
Telerik.Reporting - specifies the root element of the Telerik Reporting configuration settings. Only one
Extensions element can be used in the Telerik.Reporting element. |
<Render> element
Render XML element specifies a collection of extensions, for which configuration is applied.
| Attributes |
No attributes are defined for this element |
| Child elements |
Extension – specifies an extension, for which the configuration settings are applied. Multiple Extension elements can be applied in the Render element |
| Parent element |
Extensions - specifies a collection of extension types, for which configuration is applied. Only one Render element can be used in the Extensions element. |
<Extension> element
Extension XML element specifies an extension, for which the configuration settings are applied.
| Attributes |
name – required string attribute. Name is the key attribute that determines on which extension the configuration is to be applied. The name for every extension is defined in the class definition of the extension, in the ExtensionNameAttribute attribute.
- type – optional string attribute. It is used when new extension is added or a core extension is overridden with a new one. Specifies the name of the extension class to be used when an extension with the name specified in the name attribute is needed. Use the following format:
type="Fully qualified class name, assembly file name, version, culture, public key token"
For example : type="MyAssembly.MyExtension, MyAssembly, Version=1.0.0.0, Culture=neutral,PublicKeyToken=null"
- description - optional string attribute. Defines a description for the extension.It is used to override the default description of the extension. The reporting engine uses the description in places where the extensions are listed. For example in the Win and Web ReportViewer controls descriptions are used as labels in the dropdownwith available export formats. The default value of the description of every extension is defined in the class definition of the extension, by the ExtansionDescriptionAttribute attribute.
- visible – Optional boolean attribute(the valid values are visible=”true” or visible=”false”). The value is used to determine if the extension must be populated in the lists of available extensions. The default value is true. You can use it to hide the export format from the list of the available render extensions.
|
| Child elements |
Parameters – specifies a collection of parameters for the extension in the Extension element. Only one Parameters element can be used in the Extension element. |
| Parent element |
Render - specifies a collection of extensions, for which the configuration is applied. Multiple Extension elements can be applied in the Render element. |
<Parameters> element
Parameters XML element specifies a collection of parameters for the extension defined in the parent Extension element.
| Attributes |
No attributes are defined for this element |
| Child elements |
Parameter – specifies a parameter for the extension in the Extension element. Multiple Parameter elements can be used in the Parameters element. |
| Parent element |
- Extension - specifies an extension, for which the configuration is applied. Only one Parameters element can be applied in the Extension element. The default value is true.
You can use it to hide the export format from the list of the available render extensions.
- Provider - specifies a session state provider to register for use in the application.
|
<Parameter> element
Parameter XML element specifies a parameter for the extension defined in the ancestor Extension element. The parameter is supplied as name/value pairs.
| Attributes |
- name – the name of the parameter that is supplied. Required attribute.
- value – the value of the parameter with the name specified. As the value can be only a string, the parameter Type must have an associatedTypeConverter that handles conversions from string. Built-in .NET value types and enums have type converters defined.
|
| Child elements |
No child elements are defined for this element. |
| Parent element |
Parameters - specifies a collection of parameters for the extension defined in the parent Extension element. Multiple Parameter
elements can be used in the Parameters element. |
CopyXML <configuration>
…
<Telerik.Reporting>
<Extensions>
<Render>
<Extension name="IMAGE" description="JPEG image">
<Parameters>
<Parameter name="OutputFormat" value="JPEG"/>
</Parameters>
</Extension>
</Render>
</Extensions>
<SessionState provider="File">
<Providers>
<Provider name="File" type="Telerik.Reporting.Processing.Session.FileSessionProvider, Telerik.Reporting, Version=x.x.x.x, Culture=neutral, PublicKeyToken=a9d7983dfcc261be">
<Parameters>
<Parameter name="BasePath" value="C:\MyDataCache" />
</Parameters>
</Provider>
</Providers>
</SessionState>
</Telerik.Reporting>
…
</configuration>
<SessionState> element
The SessionState element specifies the configuration settings for the session state management system which is utilized by the viewers to store and cache rendered pages and resources.
| Attributes |
provider – required string attribute. Specifies the name of the current active session state provider used by the viewers. There are
several preconfigured providers, although additional ones can be registered in this part of the configuration section. The following
session state providers are available by default:
- Auto - the actual provider is chosen automatically according to the characteristics of the stored resource and the
permissions granted to the application;
- Memory – specifies that the rendered pages and resources are stored in memory;
- File – specifies that the rendered pages and resources are stored as temporary files in the file system;
- IsolatedStorage– specifies that the rendered pages and resources are stored as temporary files in the isolated storage.
|
| Child elements |
Providers – specifies a collection of session state providers to register for use in the application. Only one Provider child
element can be used inside the SessionState parent element. |
| Parent element |
Telerik.Reporting – specifies the root element of the Telerik Reporting configuration settings. Only one SessionState child element can be used inside
the Telerik.Reporting root element. |
<Providers> element
The Providers element specifies a collection of session state providers to register for use in the application.
| Attributes |
No attributes are defined for this element. |
| Child elements |
Provider – specifies a session state provider to register for use in the application. Multiple Provider child elements can be used inside a single Providers parent element. |
| Parent element |
SessionState – specifies the configuration settings for the session state used by the viewers. Only one Provider child element can be used inside the SessionState parent element. |
<Provider> element
The Provider element specifies a session state provider to register for use in the application.
| Attributes |
- name – required string attribute. Specifies a unique name to identify the session state provider in
the configuration section. The active session state provider specified by the provider attribute of the SessionState element should
match one of the names specified by this attribute.
- type – required string attribute. Specifies the assembly qualified type name of the session state
provider to register.
Use the following format:
type="Fully qualified class name, assembly file name, version, culture, public key token".
For example:
type="MyAssembly.MyProvider, MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null".
|
| Child elements |
Parameters – specifies a collection of parameters for the current session state provider. Only one Parameters child element can be
used in the Provider parent element. |
| Parent element |
Providers – specifies a collection of session state providers to register for use in the application. Multiple Provider child
elements can be used inside a single Providers parent element. |
Configuring Multiple Entries for a Rendering Extension
You can specify multiple instances of a single rendering extension to vary rendering behavior. If you configure multiple instances, make sure that each extension name is unique. Then you can use the rendering extension programmatically by using the extension name to identify which particular instance to use for a particular rendering operation.
You should also specify the description attribute of the Extension element. The string you specify for description will be visible to users in the list of export options for the report. If you are configuring multiple versions of the same extension, be sure to provide a value for the description. Otherwise, all versions of the extension will have the same export option name.
The following example illustrates how to use the default Image rendering extension (which produces TIFF output) alongside a second instance that outputs reports in EMF. Notice that the extension name distinguishes one instance from the other:
CopyXML <Telerik.Reporting>
<Extensions>
<Render>
<Extension name="TIFF_CCITT4"
type="Telerik.Reporting.ImageRendering.ImageReport, Telerik.Reporting, Version=x.x.x.x, Culture=neutral, PublicKeyToken=a9d7983dfcc261be"
description="TIFF file (CCITT Group 4)">
<Parameters>
<Parameter name="TiffCompression" value="ccitt4" />
</Parameters>
</Extension>
</Render>
</Extensions>
</Telerik.Reporting>
Caution | |
The code samples have the version listed as Version=x.x.x.x, and you should change that with the exact assembly version you use before proceeding.
|
Set rendering parameters programmatically
To define device rendering parameters programmatically, we need a key/value pair, and what better than a
HashTable
which represents collection of key/value pairs. If the collection contains rendering parameters that are not supported by
the specified rendering extension, they would be ignored.
CopyC# Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
Hashtable deviceInfo = new Hashtable();
deviceInfo.Add("DocumentAuthor", "John Doe");
deviceInfo.Add("DocumentTitle", "My Doc title");
Telerik.Reporting.Processing.RenderingResult result = reportProcessor.RenderReport("PDF", report1, deviceInfo);
CopyVB.NET Dim reportProcessor As New Telerik.Reporting.Processing.ReportProcessor()
Dim deviceInfo As New Hashtable()
deviceInfo.Add("DocumentAuthor", "John Doe")
deviceInfo.Add("DocumentTitle", "My Doc title")
Dim result As Telerik.Reporting.Processing.RenderingResult = reportProcessor.RenderReport("PDF", report1, deviceInfo)
See Also
|