i am using visual studio 2012 and I have a rdlc report. I want to hide word and excel in the export option in ssrs ReportViewer. I Have tried couple of things but nothing seems to work! if any body can help i'd be so grateful :)
Thanks
i am using visual studio 2012 and I have a rdlc report. I want to hide word and excel in the export option in ssrs ReportViewer. I Have tried couple of things but nothing seems to work! if any body can help i'd be so grateful :)
Thanks
Simple Jquery trick to hide Word and Excel options from RDLC Report Viewer:
$(document).ready(function() {
$("a[title='Excel']").parent().hide(); // Remove Excel from export dropdown.
$("a[title='Word']").parent().hide(); // Remove Word from export dropdown.
}
Here's a snippet from one of my projects (VB, but you can easily translate):
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
All solutions I tried did not work for me (trying to modify the m_isVisible boolean property of the RenderingExtension for example). However, the simple jquery below did work for me and is much easier to implement.
$(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();
});
You can add below code in PreRender event of your RDLC Report Viewer control
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);
}
}
}
This code was the only that worked for me. Im using a web page in asp net 4.0. I let this comment for reference, the code in at least other 10 sites didn't work for me.
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);
}
}
}