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 です。 これらの ID は RenderStream(String, String, String, String, String) メソッドに渡されます。 特定のレポートに関連付けられた外部リソース (画像など) を表示するために使用できます。

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 および ExecuteAndView
SharePoint モードで必要なアクセス許可 メイン レポートおよびすべてのサブレポート: <xref:Microsoft.SharePoint.SPBasePermissions.ViewListItems>

Render は、ExecutionInfo ヘッダーで識別されるレポート実行に関連付けられた処理済みのレポートを表示します。 処理済みのレポートの一時スナップショットが実行状態に存在しない場合、このメソッドは (資格情報とパラメーターの要件がすべて満たされれば) レポートを実行し、結果として実行状態に新しい一時スナップショットが作成されます。 非クエリのパラメーター値が変更されたためにレポートを再処理する必要がある場合は、新しい一時スナップショットが作成されます。 実行状態の詳細については、「実行状態 の識別」を参照してください。

実行オプションがキャッシュまたは実行スナップショットに設定されている場合、Render への呼び出しは既存のスナップショットを使用します。

レポートをキャッシュする設定になっていて、指定したパラメーター値と資格情報が一致する場合、実際にレポートを処理する代わりに、キャッシュされたスナップショットのコピーが読み込まれる可能性があります。

資格情報とパラメーターの要件が満たされない場合、このメソッドはエラーを返します。

表示拡張機能で複数ページの指定をサポートしている場合は、この後の Render への呼び出しを使用して、レポートの追加のページをフェッチすることができます。

出力をストリームにできないという表示方法の制約があるため、ファイル全体をメモリ内に保存する必要があります。

実行ライフ サイクルの詳細については、「 実行状態の特定 」を参照してください。これには、レポートの読み込みとレンダリングに必要な手順の説明が含まれています。

適用対象