user3113895
user3113895

Reputation: 29

How to hide the Export to Word option in SSRS Reports Tool

Ho to hide the Save as "Export to Word" option in SSRS Reports Tool . Can any one help out how to resolve the issue.

Upvotes: 1

Views: 1977

Answers (2)

Menzi
Menzi

Reputation: 365

Kalim's link will hide the options for all the reports rather than hiding it for that specific case only.

Here's an article on how to disable certain file types in SSRS Report Viewer

According to the article, add a OnPreRender action to your ReportViewer and link up in code behind.

ASPX Page:

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %> 
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></asp:ToolkitScriptManager>

<rsweb:ReportViewer ID="ReportViewer1" runat="server" 
    OnPreRender="ReportViewer1_PreRender">
</rsweb:ReportViewer>

Code Behind:

protected void ReportViewer1_PreRender(object sender, EventArgs e)
{
    DisableUnwantedExportFormat((ReportViewer)sender, "Excel");
    DisableUnwantedExportFormat((ReportViewer)sender, "Word");
} 

/// <summary>
/// Hidden the special SSRS rendering format in ReportViewer control
/// </summary>
/// <param name="ReportViewerID">The ID of the relevant ReportViewer control</param>
/// <param name="strFormatName">Format Name</param>
public void DisableUnwantedExportFormat(ReportViewer ReportViewerID, string strFormatName)
{
    FieldInfo info;
    foreach (RenderingExtension extension in ReportViewerID.LocalReport.ListRenderingExtensions())
    {
        if (extension.Name.Trim().ToUpper() == strFormatName.Trim().ToUpper())
        {
            info = extension.GetType().GetField("m_isVisible", BindingFlags.Instance | BindingFlags.NonPublic);
            info.SetValue(extension, false);
        }
    }
}

Upvotes: 1

Kalim
Kalim

Reputation: 485

Two colleagues of mine recently wrote a an article on our companies blog demonstrating exactly how to do this.

Here is the link: http://72.249.186.215/howto/wordpress/sample-page/edit-ssrs-render-format-list/

Feedback on the article would be greatly appreciated.

Let me know if this answers your question or if you need any clarity in the steps given in the article.

If you would like me to post the steps here then I can do that as well.

Upvotes: 0

Related Questions