ServerReport.Render-Methode (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.WinForms
Assembly: Microsoft.ReportViewer.WinForms (in microsoft.reportviewer.winforms.dll)
Syntax
'Declaration
'Usage
Parameter
- 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.
Rückgabewert
A Byte array of the report in the specified format.
Hinweise
The Render method can be used to export and print a report.
Beispiel
The following code example assumes a Microsoft Windows Forms project has been created with a ReportViewer control and button added to the Form. In this example, a local report is loaded into and rendered in the control and then the Rendermethod is used to export the report to Excel format:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Reporting.WinForms;
using System.IO;
namespace SampleCode
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.reportViewer1.ProcessingMode = ProcessingMode.Remote;
this.reportViewer1.ServerReport.ReportServerUrl =
new Uri(@"http://<ServerName>/reportserver");
this.reportViewer1.ServerReport.ReportPath
= @"/AdventureWorks Sample Reports/Company Sales";
this.reportViewer1.RefreshReport();
}
private void button1_Click(object sender, EventArgs e)
{
Warning[] warnings;
string[] streamids;
string mimeType;
string encoding;
string extension;
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();
MessageBox.Show("Report exported to output.xls", "Info");
}
}
}
Imports Microsoft.Reporting.WinForms
Imports System.IO
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ReportViewer1.ProcessingMode = ProcessingMode.Remote
ReportViewer1.ServerReport.ReportServerUrl = New Uri("http://<ServerName>/reportserver")
ReportViewer1.ServerReport.ReportPath = "/AdventureWorks Sample Reports/Company Sales"
Me.ReportViewer1.RefreshReport()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal 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 bytes As Byte()
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()
MessageBox.Show("Report exported to output.xls", "Info")
End Sub
End Class
Siehe auch
Verweis
ServerReport-Klasse
ServerReport-Member
Microsoft.Reporting.WinForms-Namespace