2011-03-05 149 views
0

如何實現對SQL Server報告服務擴展? 我需要爲以下內容實現呈現效果:問題實施IRenderingExtesion接口

  1. 將本地化文本應用於報告。
  2. 根據當前的文化報告應用datetime和decimal格式。
  3. 如果任何報告已分配任何報告,則使用已定義的背景圖像。

我試過爲SQL Server 2008 R2實施IRenderingInterface。 但它給在連接到報告服務我以下:

「Microsoft.SqlServer.ReportingServices2010.RSConnection2010 + MissingEndpointException:連接到該報表服務器失敗的嘗試檢查您的連接信息和報表服務器是一個兼容的版本。--- > System.InvalidOperationException:客戶端發現響應內容類型爲'',但期望'text/xml'。「

以下是渲染器類繼承IRenderingExtension &實現了所需的渲染與LocalizedName財產一起RenderStream方法:

public void GetRenderingResource(Microsoft.ReportingServices.Interfaces.CreateAndRegisterStream createAndRegisterStreamCallback, System.Collections.Specialized.NameValueCollection deviceInfo) 
{ 
    //Render any Embedded Resource in the Report 
} 

public void SetConfiguration(string configuration) 
{ 
    //Used to pass configuration from Reporting Services Config File 
    //to this Reporting Serivces Extension 
} 

public string LocalizedName 
{ 
    get 
    { 
    //A Read only properties which return the name of 
    //this RS extension 
    string p_strName = "Custom Renderer"; 

    System.Globalization.CultureInfo p_CultureInfo = System.Globalization.CultureInfo.CurrentCulture; 

    //Determine the text to be returned (displayed) by 
    // the Name property of CultureInfo class 
    if (p_CultureInfo.Name == "zh-CHS") 
    { 
     p_strName += " (Traditional Chinese)"; 
    } 
    else if (p_CultureInfo.Name == "zh-CHT") 
    { 
     p_strName += " (Simplified Chinese)"; 
    } 
    else if (p_CultureInfo.Name == "en-US") 
    { 
     p_strName += "(Traditional English)"; 
    } 
    return p_strName; 
    } 
} 

public bool Render(
    Microsoft.ReportingServices.OnDemandReportRendering.Report report, 
    System.Collections.Specialized.NameValueCollection reportServerParameters, 
    System.Collections.Specialized.NameValueCollection deviceInfo, 
    System.Collections.Specialized.NameValueCollection clientCapabilities, 
    ref System.Collections.Hashtable renderProperties, 
    Microsoft.ReportingServices.Interfaces.CreateAndRegisterStream createAndRegisterStream) 
{ 
    System.IO.Stream s = createAndRegisterStream(
     report.Name, 
     "html", 
     System.Text.Encoding.UTF8, 
     "text/html", 
     true, 
     Microsoft.ReportingServices.Interfaces.StreamOper.CreateAndRegister); 
    System.IO.StreamWriter sw = new System.IO.StreamWriter(s); 

    sw.WriteLine("<html><body>"); 
    sw.WriteLine("Testing IRenderingExtension."); 
    sw.WriteLine("</body></html>"); 
    sw.Close(); 
    s.Close(); 
    return false; 
} 

public bool RenderStream(
    string streamName, 
    Microsoft.ReportingServices.OnDemandReportRendering.Report report, 
    System.Collections.Specialized.NameValueCollection reportServerParameters, 
    System.Collections.Specialized.NameValueCollection deviceInfo, 
    System.Collections.Specialized.NameValueCollection clientCapabilities, 
    ref System.Collections.Hashtable renderProperties, 
    Microsoft.ReportingServices.Interfaces.CreateAndRegisterStream createAndRegisterStream) 
{ 
    return false; 
} 

回答

0

這可以幫助...

2點可以通過使用覆蓋=User.LanguageReport Language field

+0

問題解決了,現在我的工作定位在報表上的文本。我該怎麼做? – Kinjal 2011-03-05 13:52:06