0

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

Ramsh
  • 1
  • 1
  • 3

5 Answers5

1

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.
}
Shibu Thomas
  • 3,148
  • 2
  • 24
  • 26
0

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
Duston
  • 1,601
  • 5
  • 13
  • 24
  • I haven't used vb ever. any help on what to change?@Duston – Ramsh Mar 29 '15 at 16:13
  • rv is the ReportViewer object. Just add rv before all the . references (for example rv.Reset(), add ; at the ends of the lines and change the variable declarations. Aside from that, use Google to figure out what the VB is doing and do the same in C#. – Duston Mar 31 '15 at 15:04
0

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();  
});
0

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);
        }
    }
}
cigien
  • 57,834
  • 11
  • 73
  • 112
0

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);
        }
    }
}
Sunderam Dubey
  • 1
  • 11
  • 20
  • 40