ReportExecutionService.Render 메서드

정의

특정 보고서를 처리하고 지정된 형식으로 렌더링합니다.

public:
 cli::array <System::Byte> ^ Render(System::String ^ Format, System::String ^ DeviceInfo, [Runtime::InteropServices::Out] System::String ^ % Extension, [Runtime::InteropServices::Out] System::String ^ % MimeType, [Runtime::InteropServices::Out] System::String ^ % Encoding, [Runtime::InteropServices::Out] cli::array <ReportExecution2005::Warning ^> ^ % Warnings, [Runtime::InteropServices::Out] cli::array <System::String ^> ^ % StreamIds);
public byte[] Render (string Format, string DeviceInfo, out string Extension, out string MimeType, out string Encoding, out ReportExecution2005.Warning[] Warnings, out string[] StreamIds);
member this.Render : string * string * string * string * string * Warning[] * String[] -> byte[]
Public Function Render (Format As String, DeviceInfo As String, ByRef Extension As String, ByRef MimeType As String, ByRef Encoding As String, ByRef Warnings As Warning(), ByRef StreamIds As String()) As Byte()

매개 변수

Format
String

보고서를 렌더링할 형식입니다. 이 인수는 렌더링 확장 프로그램에 매핑됩니다. 지원되는 확장 프로그램에는 XML, NULL, CSV, IMAGE, PDF, HTML4.0, HTML3.2, MHTML, EXCEL 및 Word가 있습니다. 지원되는 확장 프로그램 목록은 ListRenderingExtensions() 메서드를 호출하여 가져올 수 있습니다.

DeviceInfo
String

매개 변수에 지정된 Format 렌더링 확장 프로그램에 필요한 디바이스별 콘텐츠를 포함하는 XML 문자열입니다. DeviceInfo 설정은 DeviceInfo XML 요소의 내부 요소로 전달되어야 합니다. 특정 출력 형식에 대한 디바이스 정보 설정에 대한 자세한 내용은 렌더링 확장 프로그램에 디바이스 정보 설정 전달을 참조하세요.

Extension
String

[out] 출력 스트림에 해당하는 파일 확장명입니다.

MimeType
String

[out] 렌더링된 보고서의 MIME 형식입니다.

Encoding
String

[out] 보고서 서버가 보고서 내용을 렌더링할 때 사용되는 인코딩입니다.

Warnings
Warning[]

[out] 보고서를 처리하는 동안 발생한 경고를 설명하는 Warning 개체의 배열입니다.

StreamIds
String[]

[out] 스트림 식별자입니다. 이러한 ID는 RenderStream(String, String, String, String, String) 메서드에 전달됩니다. 이러한 ID를 사용하여 지정된 보고서와 연결된 외부 리소스(예: 이미지)를 렌더링할 수 있습니다.

IMAGE 렌더링 확장 프로그램이 사용되는 경우 메서드는 에서 StreamIds빈 배열을 출력합니다.

반환

Byte[]

지정된 형식의 보고서의 Byte[] 배열입니다.

예제

다음 코드 예제를 컴파일하려면 Reporting Services WSDL을 참조하고 특정 네임스페이스를 가져와야 합니다. 자세한 내용은 코드 예제 컴파일 및 실행을 참조하세요. 다음 코드 예제에서는 MHTML에서 보고서를 렌더링하고 디스크에 .mht 파일로 저장합니다.

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)  

        Try  
            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  
            Console.WriteLine(e.Detail.OuterXml)  
        End Try  

        ' Write the contents of the report to an MHTML file.  
        Try  
            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.")  
            stream.Close()  
        Catch e As Exception  
            Console.WriteLine(e.Message)  
        End Try  
    End Sub 'Main  
End Class  
using System;  
using System.IO;  
using System.Web.Services.Protocols;  
using myNamespace.MyReferenceName;  

class Sample  
{  
    static void Main(string[] args)  
    {  
        ReportExecutionService rs = new ReportExecutionService();  
        rs.Credentials = System.Net.CredentialCache.DefaultCredentials;  
        rs.Url = "http://myserver/reportserver/ReportExecution2005.asmx";  

        // Render arguments  
        byte[] result = null;  
        string reportPath = "/AdventureWorks Sample Reports/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 = "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";  

        DataSourceCredentials[] credentials = null;  
        string showHideToggle = null;  
        string encoding;  
        string mimeType;  
        string extension;  
        Warning[] warnings = null;  
        ParameterValue[] reportHistoryParameters = null;  
        string[] streamIDs = null;  

        ExecutionInfo execInfo = new ExecutionInfo();  
        ExecutionHeader execHeader = new ExecutionHeader();  

        rs.ExecutionHeaderValue = execHeader;  

        execInfo = rs.LoadReport(reportPath, historyID);  

        rs.SetExecutionParameters(parameters, "en-us");   
        String SessionId = rs.ExecutionHeaderValue.ExecutionID;  

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

        try  
        {  
            result = rs.Render(format, devInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs);  

            execInfo = rs.GetExecutionInfo();  

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

        }  
        catch (SoapException e)  
        {  
            Console.WriteLine(e.Detail.OuterXml);  
        }  
        // Write the contents of the report to an MHTML file.  
        try  
        {  
            FileStream stream = File.Create("report.mht", result.Length);  
            Console.WriteLine("File created.");  
            stream.Write(result, 0, result.Length);  
            Console.WriteLine("Result written to the file.");  
            stream.Close();  
        }  
        catch (Exception e)  
        {  
            Console.WriteLine(e.Message);  
        }  

    }  
}  

설명

다음 표에서는 이 작업에 대한 헤더 및 사용 권한 정보를 보여 줍니다.

SOAP 헤더 사용 (In) TrustedUserHeaderValue

(In) ExecutionHeaderValue

(Out) ServerInfoHeaderValue
기본 모드 필수 권한 기본 보고서 및 모든 하위 보고서에서: ReadProperties ANDExecuteAndView
SharePoint 모드 필수 권한 기본 보고서 및 모든 하위 보고서에서 다음을 수행합니다.<xref:Microsoft.SharePoint.SPBasePermissions.ViewListItems>

Render 는 헤더에서 식별된 보고서 실행과 연결된 처리된 ExecutionInfo 보고서를 렌더링합니다. 실행 상태에서 처리된 보고서에 대한 임시 스냅샷 없는 경우 이 메서드는 보고서를 실행합니다(모든 자격 증명 및 매개 변수 요구 사항이 충족되는 경우). 그러면 실행 상태에 대한 임시 스냅샷 만들어집니다. 쿼리가 아닌 매개 변수 값이 변경되어 보고서가 다시 처리되면 새 임시 스냅샷 만들어집니다. 실행 상태에 대한 자세한 내용은 실행 상태 식별을 참조하세요.

실행 옵션이 캐시 또는 실행 스냅샷 설정된 경우 에 대한 호출 Render 은 기존 스냅샷 사용할 수 있습니다.

보고서가 캐시로 설정되고 제공된 매개 변수 값과 자격 증명이 일치하는 경우 실제로 보고서를 처리하는 대신 스냅샷 캐시된 복사본이 로드될 수 있습니다.

자격 증명 및 매개 변수 요구 사항이 충족되지 않으면 이 메서드는 오류를 반환합니다.

렌더링 확장 프로그램에서 여러 페이지 지정을 지원하는 경우 에 대한 후속 호출 Render 을 사용하여 보고서의 추가 페이지를 가져올 수 있습니다.

Render 메서드의 제한 사항은 출력을 스트리밍할 수 없으므로 전체 파일이 메모리에 있어야 한다는 것입니다.

보고서를 로드하고 렌더링하는 데 필요한 단계에 대한 설명이 포함된 실행 수명 주기에 대한 설명은 실행 상태 식별 을 참조하세요.

적용 대상