【问题标题】:reportviewer hide exporting to word and excel optionsreportviewer 隐藏导出到 word 和 excel 选项
【发布时间】:2015-06-01 04:06:17
【问题描述】:

我正在使用 Visual Studio 2012,并且我有一份 rdlc 报告。我想在 ssrs ReportViewer 的导出选项中隐藏 word 和 excel。我已经尝试了几件事,但似乎没有任何效果!如果有任何机构可以提供帮助,我将不胜感激:)

谢谢

【问题讨论】:

标签: c# asp.net reportviewer


【解决方案1】:

从 RDLC 报告查看器中隐藏 Word 和 Excel 选项的简单 Jquery 技巧:

$(document).ready(function() {
 $("a[title='Excel']").parent().hide(); // Remove Excel from export dropdown.
 $("a[title='Word']").parent().hide(); // Remove Word from export dropdown.
}

【讨论】:

    【解决方案2】:

    这是我的一个项目中的一个 sn-p(VB,但您可以轻松翻译):

                  With rv
                    .Reset()
                    .Visible = True
    
                    .ProcessingMode = ProcessingMode.Remote
                    .ServerReport.ReportServerUrl = New Uri(System.Configuration.ConfigurationManager.AppSettings("ReportServer"))
                    .ServerReport.ReportPath = System.Configuration.ConfigurationManager.AppSettings("ReportPath") & ssrsReportName
                    .ServerReport.ReportServerCredentials = CType(New IDOI.HealthRateReview.Common.ReportServerCredentials(), Microsoft.Reporting.WebForms.IReportServerCredentials)
                    .ServerReport.Refresh()
                    Dim wantedExportFormats As New List(Of String)
                    ' Any formats not explicitly enabled are disabled.
                    wantedExportFormats.Add("PDF")
                    wantedExportFormats.Add("CSV")
                    wantedExportFormats.Add("WORD")
                    'wantedExportFormats.Add("XML")
                    'wantedExportFormats.Add("EXCEL")
                    'wantedExportFormats.Add("MHTML")
                    'wantedExportFormats.Add("IMAGE")
                    'wantedExportFormats.Add("HTML4.0")
                    'wantedExportFormats.Add("RGDI")
                    'wantedExportFormats.Add("RPL")
                    'wantedExportFormats.Add("XLTemplate")
                    'wantedExportFormats.Add("WordTemplate")
                    'wantedExportFormats.Add("NULL")
                    EnableWantedExportFormats(rv.ServerReport, wantedExportFormats)
                    '.ServerReport.ListRenderingExtensions()
                    .AsyncRendering = True
                End With
    

    【讨论】:

    • 我没用过vb。有什么改变的帮助吗?@Duston
    • rv 是 ReportViewer 对象。只需在所有 .引用(例如 rv.Reset(),在行尾添加 ; 并更改变量声明。除此之外,使用 Google 找出 VB 正在做什么并在 C# 中做同样的事情。
    【解决方案3】:

    我尝试过的所有解决方案都对我不起作用(例如,尝试修改 RenderingExtension 的 m_isVisible 布尔属性)。但是,下面的简单 jquery 确实对我有用,并且更容易实现。

    $(document).ready(function () {
        $("a[title='PDF']").parent().hide();  // Remove from export dropdown.
        $("a[title='MHTML (web archive)']").parent().hide();  
        $("a[title='TIFF file']").parent().hide();  
    });
    

    【讨论】:

      【解决方案4】:

      您可以在 RDLC Report Viewer 控件的 PreRender 事件中添加以下代码

      protected void ReportViewer1_PreRender(object sender, EventArgs e)
      {
          foreach (RenderingExtension extension in ReportViewer1.LocalReport.ListRenderingExtensions())
          {
              if(extension.Name.ToUpper()=="WORDOPENXML" || extension.Name.ToUpper()=="EXCEL" || extension.Name.ToUpper()=="WORD" ||extension.Name.ToUpper()=="EXCELOPENXML" )
              {
                  FieldInfo fi = extension.GetType().GetField("m_isVisible",BindingFlags.Instance | BindingFlags.NonPublic);
                  fi.SetValue(extension, false);
              }
          }
      }
      

      【讨论】:

        猜你喜欢
        • 2010-12-02
        • 2013-04-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-02-09
        • 2021-12-26
        • 1970-01-01
        相关资源
        最近更新 更多