Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize

Render Method

SQL Server 2000

ReportingService.Render Method

Processes a specific report and renders it in the specified format.

Public Function Render( _
   ByVal Report As String _
   ByVal Format As String _
   ByVal HistoryID As String _
   ByVal DeviceInfo As String _
   ByVal Parameters() As [Namespace].ParameterValue _
   ByVal Credentials() As [Namespace].DataSourceCredentials _
   ByVal ShowHideToggle As String _
   ByRef Encoding As String _
   ByRef MimeType As String _
   ByRef ParametersUsed() As [Namespace].ParameterValue _
   ByRef Warnings() As [Namespace].Warning _
   ByRef StreamIds() As String _
) As Byte()
   Member of [Namespace].ReportingService

public Byte[] Render(
   string Report,
   string Format,
   string HistoryID,
   string DeviceInfo,
   [Namespace].ParameterValue[] Parameters,
   [Namespace].DataSourceCredentials[] Credentials,
   string ShowHideToggle,
   out string Encoding,
   out string MimeType,
   out [Namespace].ParameterValue[] ParametersUsed,
   out [Namespace].Warning[] Warnings
   out string[] StreamIds);
   Member of [Namespace].ReportingService
The full path name of the report.
The format in which to render the report. This argument maps to a rendering extension. Supported extensions are XML, NULL, CSV, IMAGE, PDF, HTML4.0, HTML3.2, MHTML, EXCEL, and HTMLOWC.
Optional. The unique identifier of a report history snapshot to render for the specified report. The identifier is based on the date and time the report history was created.
An XML string that contains the device-specific content that is required by the rendering extension specified in the Format parameter. For more information about device information settings for specific output formats, see Device Information Settings.
Optional. An array of ParameterValue[] objects that represent the report-specific parameters.
Optional. An array of DataSourceCredentials[] objects that contains the data source credentials.
Optional. The Show/Hide toggle ID.
[out] The encoding used when report server renders the contents of the report.
[out] The MIME type of the rendered report.
[out] An array of ParameterValue[] objects representing the query parameters, if any, that are stored along with the report. This parameter returns a value only if the report being rendered is a report history snapshot.
[out] An array of Warning[] objects that describes any warnings that occurred during report processing.
[out] The stream identifiers. These IDs are passed to the RenderStream method. You can use them to render the external resources (images, etc.) that are associated with a given report.
Return Value

A Byte[] array of the report in the specified format. For more information about this data type, see "Byte Structure" in the .NET Framework documentation.


Operation Description
Read Properties Required on the report and any corresponding subreports being rendered.
Execute and View Required on the report and any corresponding subreports being rendered.


You can use the ListExtensions method to retrieve a list of supported rendering extensions.

A value for the SessionId property is automatically provided in the Sessionheader object when the call to the Render method is made, and a new session is created. Subsequent calls to the Web service using the same proxy object are made by the report server under the same session unless you explicitly clear the session. For more information about the SessionHeader class, see SessionHeader Class.

Subsequent calls to the Render method can be made to retrieve additional report pages if the rendering extension supports additional pages and searching. For more information about sessions in Reporting Services, see Identifying Session State.

If the report is a linked report, the definition is retrieved from the referenced report before execution.

If a value for the HistoryID parameter is not specified, based on the execution and cache management option set for the report, the report can be executed and rendered directly from a data source or from a cached copy. For more information about execution settings, see Setting Execution Properties.

The SessionHeader.IsNewExecution property is set to true when the rendered report that is returned was generated from a query against its data sources. This property is set to false if the report is rendered directly from session or cache.

You can pass device information settings to the rendering extension you are targeting in the Render method to configure the output of your report. For more information about device information settings, see Device Information Settings.

For multi-stream rendering extensions, such as HTML 3.2 and HTML 4.0, you can pass the stream ID's that are returned in the StreamIds out parameter to the RenderStream method to render these external resources. Single-stream rendering extensions, such as Web archive (MHTML) or Excel, do not return any additional stream ID's.

If you render a report to HTML using the Render method, you cannot use the report viewer toolbar as you can with a report that is rendered using URL access. However, the Toolbar device information setting still affects the appearance of the report. If you set Toolbar to a value of true, the report server only renders the first page of the HTML report. If you set the value to false, the report server renders all pages into a single Web page, using <HR> tags as page delimiters.


To compile the following code example, you must reference the Reporting Services WSDL and import certain namespaces. For more information, see Compiling and Running Code Examples. The following code example renders a report in HTML 4.0 and saves it as an .htm file to disk:

Imports System
Imports System.IO
Imports System.Web.Services.Protocols

Class Sample
   Public Shared Sub Main()
      Dim rs As New ReportingService()
      rs.Credentials = System.Net.CredentialCache.DefaultCredentials
      ' Render arguments
      Dim result As Byte() = Nothing
      Dim reportPath As String = "/SampleReports/Employee Sales Summary"
      Dim format As String = "MHTML"
      Dim historyID As String = Nothing
      Dim devInfo As String = "<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>"
      ' Prepare report parameter.
      Dim parameters(2) As ParameterValue
      parameters(0) = New ParameterValue()
      parameters(0).Name = "EmpID"
      parameters(0).Value = "38"
      parameters(1) = New ParameterValue()
      parameters(1).Name = "ReportMonth"
      parameters(1).Value = "6" ' June
      parameters(2) = New ParameterValue()
      parameters(2).Name = "ReportYear"
      parameters(2).Value = "2004"
      Dim credentials As DataSourceCredentials() = Nothing
      Dim showHideToggle As String = Nothing
      Dim encoding As String
      Dim mimeType As String
      Dim warnings As Warning() = Nothing
      Dim reportHistoryParameters As ParameterValue() = Nothing
      Dim streamIDs As String() = Nothing
      Dim sh As New SessionHeader()
      rs.SessionHeaderValue = sh
         result = rs.Render(reportPath, format, historyID, devInfo, parameters, _
            credentials, showHideToggle, encoding, mimeType, reportHistoryParameters, warnings, streamIDs)
         sh.SessionId = rs.SessionHeaderValue.SessionId
         Console.WriteLine("SessionID after call to Render: {0}", rs.SessionHeaderValue.SessionId)
         Console.WriteLine("Execution date and time: {0}", rs.SessionHeaderValue.ExecutionDateTime)
         Console.WriteLine("Is new execution: {0}", rs.SessionHeaderValue.IsNewExecution)
      Catch e As SoapException
      End Try
      ' Write the contents of the report to an MHTML file.
         Dim stream As FileStream = File.Create("report.mhtml", result.Length)
         Console.WriteLine("File created.")
         stream.Write(result, 0, result.Length)
         Console.WriteLine("Result written to the file.")
      Catch e As Exception
      End Try
   End Sub 'Main
End Class 'Sample

using System;
using System.IO;
using System.Web.Services.Protocols;

class Sample
   public static void Main()
      ReportingService rs = new ReportingService();
      rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
      // Render arguments
      byte[] result = null;
      string reportPath = "/SampleReports/Employee Sales Summary";
      string format = "MHTML";
      string historyID = null;
      string devInfo = @"<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>";

      // Prepare report parameter.
      ParameterValue[] parameters = new ParameterValue[3];
      parameters[0] = new ParameterValue();
      parameters[0].Name = "EmpID";
      parameters[0].Value = "38";
      parameters[1] = new ParameterValue();
      parameters[1].Name = "ReportMonth";
      parameters[1].Value = "6"; // June
      parameters[2] = new ParameterValue();
      parameters[2].Name = "ReportYear";
      parameters[2].Value = "2004";

      DataSourceCredentials[] credentials = null;
      string showHideToggle = null;
      string encoding;
      string mimeType;
      Warning[] warnings = null;
      ParameterValue[] reportHistoryParameters = null;
      string[] streamIDs = null;
      SessionHeader sh = new SessionHeader();
      rs.SessionHeaderValue = sh;

         result = rs.Render(reportPath, format, historyID, devInfo, parameters, credentials, 
            showHideToggle, out encoding, out mimeType, out reportHistoryParameters, out warnings,
            out streamIDs);
         sh.SessionId = rs.SessionHeaderValue.SessionId;
         Console.WriteLine("SessionID after call to Render: {0}", 
         Console.WriteLine("Execution date and time: {0}",
         Console.WriteLine("Is new execution: {0}",
      catch (SoapException e)
      // Write the contents of the report to an MHTML file.
         FileStream stream = File.Create( "report.mhtml", result.Length );
         Console.WriteLine( "File created." );
         stream.Write( result, 0, result.Length );
         Console.WriteLine( "Result written to the file." );
      catch ( Exception e )
         Console.WriteLine( e.Message );
See Also


ReportingService Class

Reporting Services Web Service Library

© 2015 Microsoft