【发布时间】:2015-06-01 04:06:17
【问题描述】:
我正在使用 Visual Studio 2012,并且我有一份 rdlc 报告。我想在 ssrs ReportViewer 的导出选项中隐藏 word 和 excel。我已经尝试了几件事,但似乎没有任何效果!如果有任何机构可以提供帮助,我将不胜感激:)
谢谢
【问题讨论】:
标签: c# asp.net reportviewer
我正在使用 Visual Studio 2012,并且我有一份 rdlc 报告。我想在 ssrs ReportViewer 的导出选项中隐藏 word 和 excel。我已经尝试了几件事,但似乎没有任何效果!如果有任何机构可以提供帮助,我将不胜感激:)
谢谢
【问题讨论】:
标签: c# asp.net reportviewer
从 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.
}
【讨论】:
这是我的一个项目中的一个 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
【讨论】:
我尝试过的所有解决方案都对我不起作用(例如,尝试修改 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();
});
【讨论】:
您可以在 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);
}
}
}
【讨论】: