ServerReport.Render Method (String, String, out String, out String, out String, out String[], out Warning[])
Processes the report and renders it in the specified format.
Namespace: Microsoft.Reporting.WebForms
Assembly: Microsoft.ReportViewer.WebForms (in microsoft.reportviewer.webforms.dll)
Syntax
'Declaration
Public Overrides Function Render ( _
format As String, _
deviceInfo As String, _
<OutAttribute> ByRef mimeType As String, _
<OutAttribute> ByRef encoding As String, _
<OutAttribute> ByRef fileNameExtension As String, _
<OutAttribute> ByRef streams As String(), _
<OutAttribute> ByRef warnings As Warning() _
) As Byte()
'Usage
Dim instance As ServerReport
Dim format As String
Dim deviceInfo As String
Dim mimeType As String
Dim encoding As String
Dim fileNameExtension As String
Dim streams As String()
Dim warnings As Warning()
Dim returnValue As Byte()
returnValue = instance.Render(format, deviceInfo, mimeType, encoding, fileNameExtension, streams, warnings)
public override byte[] Render (
string format,
string deviceInfo,
out string mimeType,
out string encoding,
out string fileNameExtension,
out string[] streams,
out Warning[] warnings
)
public:
virtual array<unsigned char>^ Render (
String^ format,
String^ deviceInfo,
[OutAttribute] String^% mimeType,
[OutAttribute] String^% encoding,
[OutAttribute] String^% fileNameExtension,
[OutAttribute] array<String^>^% streams,
[OutAttribute] array<Warning^>^% warnings
) override
public byte[] Render (
String format,
String deviceInfo,
/** @attribute OutAttribute() */ /** @ref */ String mimeType,
/** @attribute OutAttribute() */ /** @ref */ String encoding,
/** @attribute OutAttribute() */ /** @ref */ String fileNameExtension,
/** @attribute OutAttribute() */ /** @ref */ String[] streams,
/** @attribute OutAttribute() */ /** @ref */ Warning[] warnings
)
JScript does not support passing value-type arguments by reference.
Parameters
- format
The format in which to render the report. This argument maps to a rendering extension. Supported formats include Microsoft Office Excel, PDF, and Image.
- deviceInfo
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" in SQL Server Books Online.
- mimeType
[out] The MIME type of the rendered report.
- encoding
[out] The encoding used when rendering the contents of the report.
- fileNameExtension
[out] The file name extension used for the output file.
- streams
[out] The stream identifiers. You can use them to render external resources (images, for example) that are associated with the report.
- warnings
[out] An array of Warning objects that describes any warnings that occurred during report processing.
Return Value
A Byte array of the report in the specified format.
Remarks
The Render method can be used to export and print a report.
Example
The following code example assumes a Web Site has been created with a ReportViewer control and a button added to the Page. In this example, a local report is loaded into and rendered in the control and then the Render method is used to export the report to Microsoft Excel format:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using Microsoft.Reporting.WebForms;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ReportViewer1.ProcessingMode = ProcessingMode.Remote;
ReportViewer1.ServerReport.ReportServerUrl =
new Uri(@"http://myserver/reportserver");
ReportViewer1.ServerReport.ReportPath
= @"/AdventureWorks Sample Reports/Company Sales";
}
protected void Button1_Click(object sender, EventArgs e)
{
Warning[] warnings;
string[] streamids;
string mimeType;
string encoding;
string extension;
string deviceInfo;
deviceInfo = "<DeviceInfo><SimplePageHeaders>True</SimplePageHeaders></DeviceInfo>";
byte[] bytes = ReportViewer1.ServerReport.Render(
"Excel", null, out mimeType, out encoding, out extension,
out streamids, out warnings);
FileStream fs =
new FileStream(@"c:\output.xls", FileMode.Create);
fs.Write(bytes, 0, bytes.Length);
fs.Close();
}
}
Imports Microsoft.Reporting.WebForms
Imports System.IO
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Me.Load
ReportViewer1.ProcessingMode = ProcessingMode.Remote
ReportViewer1.ServerReport.ReportServerUrl =_
New Uri("http://myserver/reportserver")
ReportViewer1.ServerReport.ReportPath = _
"/AdventureWorks Sample Reports/Company Sales"
End Sub
Protected Sub Button1_Click(ByVal sender As Object,_
B yVal e As System.EventArgs) Handles Button1.Click
Dim warnings As Warning() = Nothing
Dim streamids As String() = Nothing
Dim mimeType As String = Nothing
Dim encoding As String = Nothing
Dim extension As String = Nothing
Dim deviceInfo as String
Dim bytes As Byte()
deviceInfo = _
"<DeviceInfo><SimplePageHeaders>True</SimplePageHeaders></DeviceInfo>"
bytes = ReportViewer1.ServerReport.Render("Excel", _
Nothing, mimeType, _
encoding, extension, streamids, warnings)
Dim fs As New FileStream("c:\output.xls", _
FileMode.Create)
fs.Write(bytes, 0, bytes.Length)
fs.Close()
End Sub
End Class
See Also
Reference
ServerReport Class
ServerReport Members
Microsoft.Reporting.WebForms Namespace