Render メソッド

特定のレポートを処理し、指定した形式で表示します。

名前空間:  ReportExecution2005
アセンブリ:  ReportExecution2005 (ReportExecution2005.dll)

構文

'宣言
<SoapHeaderAttribute("ExecutionHeaderValue")> _
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices/Render", RequestNamespace := "https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices",  _
    ResponseNamespace := "https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices",  _
    Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
<SoapHeaderAttribute("TrustedUserHeaderValue")> _
<SoapHeaderAttribute("ServerInfoHeaderValue", Direction := SoapHeaderDirection.Out)> _
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()
'使用
Dim instance As ReportExecutionService
Dim Format As String
Dim DeviceInfo As String
Dim Extension As String
Dim MimeType As String
Dim Encoding As String
Dim Warnings As Warning()
Dim StreamIds As String()
Dim returnValue As Byte()

returnValue = instance.Render(Format, _
    DeviceInfo, Extension, MimeType, _
    Encoding, Warnings, StreamIds)
[SoapHeaderAttribute("ExecutionHeaderValue")]
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices/Render", RequestNamespace = "https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices", 
    ResponseNamespace = "https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices", 
    Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
[SoapHeaderAttribute("TrustedUserHeaderValue")]
[SoapHeaderAttribute("ServerInfoHeaderValue", Direction = SoapHeaderDirection.Out)]
public byte[] Render(
    string Format,
    string DeviceInfo,
    out string Extension,
    out string MimeType,
    out string Encoding,
    out Warning[] Warnings,
    out string[] StreamIds
)
[SoapHeaderAttribute(L"ExecutionHeaderValue")]
[SoapDocumentMethodAttribute(L"https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices/Render", RequestNamespace = L"https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices", 
    ResponseNamespace = L"https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices", 
    Use = SoapBindingUse::Literal, ParameterStyle = SoapParameterStyle::Wrapped)]
[SoapHeaderAttribute(L"TrustedUserHeaderValue")]
[SoapHeaderAttribute(L"ServerInfoHeaderValue", Direction = SoapHeaderDirection::Out)]
public:
array<unsigned char>^ Render(
    String^ Format, 
    String^ DeviceInfo, 
    [OutAttribute] String^% Extension, 
    [OutAttribute] String^% MimeType, 
    [OutAttribute] String^% Encoding, 
    [OutAttribute] array<Warning^>^% Warnings, 
    [OutAttribute] array<String^>^% StreamIds
)
[<SoapHeaderAttribute("ExecutionHeaderValue")>]
[<SoapDocumentMethodAttribute("https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices/Render", RequestNamespace = "https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices", 
    ResponseNamespace = "https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices", 
    Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)>]
[<SoapHeaderAttribute("TrustedUserHeaderValue")>]
[<SoapHeaderAttribute("ServerInfoHeaderValue", Direction = SoapHeaderDirection.Out)>]
member Render : 
        Format:string * 
        DeviceInfo:string * 
        Extension:string byref * 
        MimeType:string byref * 
        Encoding:string byref * 
        Warnings:Warning[] byref * 
        StreamIds:string[] byref -> byte[] 
public function Render(
    Format : String, 
    DeviceInfo : String, 
    Extension : String, 
    MimeType : String, 
    Encoding : String, 
    Warnings : Warning[], 
    StreamIds : String[]
) : byte[]

パラメーター

  • Format
    型: System. . :: . .String
    レポートを表示する形式です。この引数は、表示拡張機能にマップされます。サポートされる拡張機能には、XML、NULL、CSV、IMAGE、PDF、HTML4.0、HTML3.2、MHTML、EXCEL、Word があります。サポートされる拡張機能の一覧は、ListRenderingExtensions メソッドを呼び出すことによって取得できます。
  • DeviceInfo
    型: System. . :: . .String
    Format パラメーターで指定する表示拡張機能に必要なデバイス固有のコンテンツを含む XML 文字列です。DeviceInfo 設定は、DeviceInfo XML 要素の内部要素として渡す必要があります。特定の出力形式に対応するデバイス情報設定の詳細については、「Reporting Services デバイス情報設定」を参照してください。
  • Extension
    型: System. . :: . .String%
    [out] 出力ストリームに対応するファイル拡張子です。
  • Encoding
    型: System. . :: . .String%
    [out] レポート サーバーがレポートのコンテンツの表示に使用するエンコードです。
  • StreamIds
    型: array<System. . :: . .String> [] () [] []%
    [out] ストリーム ID です。これらの ID は RenderStream メソッドに渡されます。特定のレポートに関連付けられた外部リソース (画像など) を表示するために使用できます。

戻り値

型: array<System. . :: . .Byte> [] () [] []
指定された形式でのレポートの Byte[] 配列です。

説明

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

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

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

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

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

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

レポートの読み込みと表示に必要な手順の説明など、実行のライフ サイクルの詳細については、「実行状態の識別」を参照してください。

使用例

次のコード例をコンパイルするには、Reporting Services の WSDL を参照し、特定の名前空間をインポートする必要があります。詳細については、「Compiling and Running Code Examples」を参照してください。次のコード例では、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);
        }

    }
}