Wednesday 9 December 2015

How to disable Excel export option in ssrs report

How to disable Excel export option in ssrs report.


By using below code you can achieve to disable SSRS report Excel export option.

public void DisableUnwantedExportFormat(ReportViewer reportViewer, string strFormatName)
        {
            FieldInfo info;
            foreach (RenderingExtension extension in reportViewer.LocalReport.ListRenderingExtensions())
            {
                if (extension.Name.Trim().ToUpper() == strFormatName.Trim().ToUpper())
                {
                    info = extension.GetType().GetField("m_isVisible", BindingFlags.Instance | BindingFlags.NonPublic);
                    info.SetValue(extension, false);
                }
            }

        }


Above code will set visible property to false. Call below method to disable the Excel format.

DisableUnwantedExportFormat(viewerInstance, "Excel");


No comments:

Post a Comment