Render Method

ReportExecutionService.Render Method (String, String, String, String, String, Warning(), String())


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

Namespace:   ReportExecution2005
Assembly:  ReportExecution2005 (in ReportExecution2005.dll)

Public Function Render (
	Format As String,
	DeviceInfo As String,
	<OutAttribute> ByRef Extension As String,
	<OutAttribute> ByRef MimeType As String,
	<OutAttribute> ByRef Encoding As String,
	<OutAttribute> ByRef Warnings As Warning(),
	<OutAttribute> ByRef StreamIds As String()
) As Byte()


Type: System.String

The format in which to render the report. This argument maps to a rendering extension. Supported extensions include XML, NULL, CSV, IMAGE, PDF, HTML4.0, HTML3.2, MHTML, EXCEL, and Word. A list of supported extensions may be obtained by calling the ListRenderingExtensions method.

Type: System.String

An XML string that contains the device-specific content that is required by the rendering extension specified in the Format parameter. DeviceInfo settings must be passed as internal elements of a DeviceInfo XML element. For more information about device information settings for specific output formats, see Passing Device Information Settings to Rendering Extensions.

Type: System.String

[out] The file extension corresponding to the output stream.

Type: System.String

[out] The MIME type of the rendered report.

Type: System.String

[out] The encoding used when report server renders the contents of the report.

Type: ReportExecution2005.Warning()

[out] An array of Warning objects that describes any warnings that occurred during report processing.

Type: System.String()

[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.

If the IMAGE rendering extension is used, the method outputs an empty array in StreamIds.

Return Value

Type: System.Byte()

A Byte[] array of the report in the specified format.

The table below shows header and permissions information on this operation.

SOAP Header Usage

(In) TrustedUserHeaderValue

(In) ExecutionHeaderValue

(Out) ServerInfoHeaderValue

Native Mode Required Permissions

On the main report and all subreports: ReadProperties AND ExecuteAndView

SharePoint Mode Required Permissions

On the main report and all subreports: ViewListItems

Render renders a processed report associated with the report execution identified in the ExecutionInfo header. If no temporary snapshot exists for the processed report in the execution state, this method will execute the report (if all credential and parameter requirements are met), resulting in a temporary snapshot being created for the execution state. If the report is reprocessed because non-query parameter values have changed, a new temporary snapshot is created. For more information on execution state, see Identifying Execution State.

If the execution options are set to cache or execution snapshot, the call to Render may use an existing snapshot.

If the report is set to cache and the supplied parameter values and credentials match, the cached copy of the snapshot may be loaded instead of actually processing the report.

If credential and parameter requirements are not met, this method will return an error.

Subsequent calls to Render can be used to fetch additional pages of the report if the rendering extension supports specifying multiple pages.

A limitation of the Render method is that the output cannot be streamed, so the entire file must be in-memory.

Please see Identifying Execution State for a discussion of the execution life cycle, which includes a description of the steps necessary to load and render a report.

To compile the following code example, you must reference the Reporting Services WSDL and import certain namespaces. For more information, see . The following code example renders a report in MHTML and saves it as an .mht file to disk.317946aa-8e95-4f0b-8170-394c9d5e184e

Imports System
Imports System.IO
Imports System.Web.Services.Protocols
Imports myNamespace.MyReferenceName

Class Sample
    Public Shared Sub Main()
        Dim rs As New ReportExecutionService()
        rs.Credentials = System.Net.CredentialCache.DefaultCredentials
        rs.Url = "http://myserver/reportserver/ReportExecution2005.asmx"

        ' Render arguments
        Dim result As Byte() = Nothing
        Dim reportPath As String = "/AdventureWorks Sample Reports/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 = "288"
        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 execInfo As New ExecutionInfo
        Dim execHeader As New ExecutionHeader()
        Dim SessionId As String
        Dim extension As String = ""

        rs.ExecutionHeaderValue = execHeader

        execInfo = rs.LoadReport(reportPath, historyID)

        rs.SetExecutionParameters(parameters, "en-us")

        SessionId = rs.ExecutionHeaderValue.ExecutionID
        Console.WriteLine("SessionID: {0}", rs.ExecutionHeaderValue.ExecutionID)

            result = rs.Render(format, devInfo, extension, _
               encoding, mimeType, warnings, streamIDs)

            execInfo = rs.GetExecutionInfo()

            Console.WriteLine("Execution date and time: {0}", execInfo.ExecutionDateTime)

        Catch e As SoapException
        End Try

        ' Write the contents of the report to an MHTML file.
            Dim stream As FileStream = File.Create("report.mht", 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
Return to top
© 2015 Microsoft