<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Disabling Export Formats in Reporting Services</title>
	<atom:link href="http://mikemason.ca/blog/2007/04/disabling-export-formats-in-reporting-services/feed/" rel="self" type="application/rss+xml" />
	<link>http://mikemason.ca/blog/2007/04/disabling-export-formats-in-reporting-services/</link>
	<description>agile thinking</description>
	<lastBuildDate>Mon, 28 Dec 2009 21:52:40 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Chad</title>
		<link>http://mikemason.ca/blog/2007/04/disabling-export-formats-in-reporting-services/comment-page-1/#comment-28847</link>
		<dc:creator>Chad</dc:creator>
		<pubDate>Mon, 28 Dec 2009 21:52:40 +0000</pubDate>
		<guid isPermaLink="false">http://mikemason.ca/blog/?p=4#comment-28847</guid>
		<description>I am working for a company that has Reporting Services 2008, SQL SERVER 2008 and develops with VB.  Here is the converted VB code.

Public Class ServerReportDecorator
        Private ReadOnly serverReport As ServerReport

        Public Sub New(ByVal reportViewer As ReportViewer)
            Me.serverReport = reportViewer.ServerReport
        End Sub

        Public Sub New(ByVal serverReport As ServerReport)
            Me.serverReport = serverReport
        End Sub

        Public Sub DisableUnwantedExportFormats()
            For Each extension As RenderingExtension In serverReport.ListRenderingExtensions()
                If extension.Name = &quot;XML&quot; Or extension.Name = &quot;IMAGE&quot; Or extension.Name = &quot;MHTML&quot; Or extension.Name = &quot;EXCEL&quot; Or extension.Name = &quot;WORD&quot; Then
                    ReflectivelySetVisibilityFalse(extension)
                End If
            Next
        End Sub

        Private Sub ReflectivelySetVisibilityFalse(ByVal extension As RenderingExtension)
            Dim info As FieldInfo = extension.GetType().GetField(&quot;m_isVisible&quot;, BindingFlags.NonPublic Or BindingFlags.Instance)

            If Not info Is Nothing Then
                info.SetValue(extension, False)
            End If
        End Sub
    End Class</description>
		<content:encoded><![CDATA[<p>I am working for a company that has Reporting Services 2008, SQL SERVER 2008 and develops with VB.  Here is the converted VB code.</p>
<p>Public Class ServerReportDecorator<br />
        Private ReadOnly serverReport As ServerReport</p>
<p>        Public Sub New(ByVal reportViewer As ReportViewer)<br />
            Me.serverReport = reportViewer.ServerReport<br />
        End Sub</p>
<p>        Public Sub New(ByVal serverReport As ServerReport)<br />
            Me.serverReport = serverReport<br />
        End Sub</p>
<p>        Public Sub DisableUnwantedExportFormats()<br />
            For Each extension As RenderingExtension In serverReport.ListRenderingExtensions()<br />
                If extension.Name = &#8220;XML&#8221; Or extension.Name = &#8220;IMAGE&#8221; Or extension.Name = &#8220;MHTML&#8221; Or extension.Name = &#8220;EXCEL&#8221; Or extension.Name = &#8220;WORD&#8221; Then<br />
                    ReflectivelySetVisibilityFalse(extension)<br />
                End If<br />
            Next<br />
        End Sub</p>
<p>        Private Sub ReflectivelySetVisibilityFalse(ByVal extension As RenderingExtension)<br />
            Dim info As FieldInfo = extension.GetType().GetField(&#8220;m_isVisible&#8221;, BindingFlags.NonPublic Or BindingFlags.Instance)</p>
<p>            If Not info Is Nothing Then<br />
                info.SetValue(extension, False)<br />
            End If<br />
        End Sub<br />
    End Class</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob Kostecki</title>
		<link>http://mikemason.ca/blog/2007/04/disabling-export-formats-in-reporting-services/comment-page-1/#comment-26420</link>
		<dc:creator>Rob Kostecki</dc:creator>
		<pubDate>Wed, 11 Nov 2009 20:09:03 +0000</pubDate>
		<guid isPermaLink="false">http://mikemason.ca/blog/?p=4#comment-26420</guid>
		<description>I stumbled across similar challenge today using VS 2008 and SQL 2005 (9.00.4035.00). I found out that the “m_serverExtension” actually does not exists nor “Visible”. So just for a quick reference please find the code below. 
Bear in mind you will have to reference System.Reflection namespace. Also using Microsoft.SqlServer.ReportingServices2005.Execution namespace is not required nor Microsoft.ReportViewer.Common.dll assembly ref.


public void DisableUnwantedExportFormats()
{

    FieldInfo info;

    foreach (RenderingExtension extension in rvMain.ServerReport.ListRenderingExtensions())
    {
        if (extension.Name != &quot;PDF&quot; &amp;&amp; extension.Name != &quot;EXCEL&quot;) // only PDF and Excel - remove the others
        {
            info = extension.GetType().GetField(&quot;m_isVisible&quot;, BindingFlags.Instance &#124; BindingFlags.NonPublic);
            info.SetValue(extension, false);
        }

        if (extension.Name == &quot;EXCEL&quot;) // change &quot;Excel&quot; name on the list to &quot;Excel 97-2003 Workbook&quot;
        {
            info = extension.GetType().GetField(&quot;m_localizedName&quot;, BindingFlags.Instance &#124; BindingFlags.NonPublic);
            if (info != null) info.SetValue(extension, &quot;Excel 97-2003 Workbook&quot;);
        }
    }
}

Hope this helps!</description>
		<content:encoded><![CDATA[<p>I stumbled across similar challenge today using VS 2008 and SQL 2005 (9.00.4035.00). I found out that the “m_serverExtension” actually does not exists nor “Visible”. So just for a quick reference please find the code below.<br />
Bear in mind you will have to reference System.Reflection namespace. Also using Microsoft.SqlServer.ReportingServices2005.Execution namespace is not required nor Microsoft.ReportViewer.Common.dll assembly ref.</p>
<p>public void DisableUnwantedExportFormats()<br />
{</p>
<p>    FieldInfo info;</p>
<p>    foreach (RenderingExtension extension in rvMain.ServerReport.ListRenderingExtensions())<br />
    {<br />
        if (extension.Name != &#8220;PDF&#8221; &amp;&amp; extension.Name != &#8220;EXCEL&#8221;) // only PDF and Excel &#8211; remove the others<br />
        {<br />
            info = extension.GetType().GetField(&#8220;m_isVisible&#8221;, BindingFlags.Instance | BindingFlags.NonPublic);<br />
            info.SetValue(extension, false);<br />
        }</p>
<p>        if (extension.Name == &#8220;EXCEL&#8221;) // change &#8220;Excel&#8221; name on the list to &#8220;Excel 97-2003 Workbook&#8221;<br />
        {<br />
            info = extension.GetType().GetField(&#8220;m_localizedName&#8221;, BindingFlags.Instance | BindingFlags.NonPublic);<br />
            if (info != null) info.SetValue(extension, &#8220;Excel 97-2003 Workbook&#8221;);<br />
        }<br />
    }<br />
}</p>
<p>Hope this helps!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: [c#] Microsoft Report Viewer - Forum Fachinformatiker.de</title>
		<link>http://mikemason.ca/blog/2007/04/disabling-export-formats-in-reporting-services/comment-page-1/#comment-21707</link>
		<dc:creator>[c#] Microsoft Report Viewer - Forum Fachinformatiker.de</dc:creator>
		<pubDate>Fri, 07 Aug 2009 08:30:05 +0000</pubDate>
		<guid isPermaLink="false">http://mikemason.ca/blog/?p=4#comment-21707</guid>
		<description>[...] f</description>
		<content:encoded><![CDATA[<p>[...] f</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mike</title>
		<link>http://mikemason.ca/blog/2007/04/disabling-export-formats-in-reporting-services/comment-page-1/#comment-16668</link>
		<dc:creator>mike</dc:creator>
		<pubDate>Mon, 18 May 2009 15:34:27 +0000</pubDate>
		<guid isPermaLink="false">http://mikemason.ca/blog/?p=4#comment-16668</guid>
		<description>If you&#039;re using Reporting Services with a DLL version of 9.0.0.0 (2008?) try Giulliano&#039;s code snippet instead. My code example only works with Reporting Services 2005.</description>
		<content:encoded><![CDATA[<p>If you&#8217;re using Reporting Services with a DLL version of 9.0.0.0 (2008?) try Giulliano&#8217;s code snippet instead. My code example only works with Reporting Services 2005.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon</title>
		<link>http://mikemason.ca/blog/2007/04/disabling-export-formats-in-reporting-services/comment-page-1/#comment-16488</link>
		<dc:creator>Jon</dc:creator>
		<pubDate>Fri, 15 May 2009 23:57:14 +0000</pubDate>
		<guid isPermaLink="false">http://mikemason.ca/blog/?p=4#comment-16488</guid>
		<description>I tried below code in my ReportViewer page, but does not work.  Please help.  Thanks,

           foreach (RenderingExtension extension in ReportViewer1.ServerReport.ListRenderingExtensions())
            {
                if (extension.Name == &quot;XML&quot;)
                {
                    FieldInfo info = extension.GetType().GetField(&quot;m_isVisible&quot;, BindingFlags.NonPublic &#124; BindingFlags.Instance);
                    if (info != null)
                    {
                        info.SetValue(extension, false);
                    }
                }

            }</description>
		<content:encoded><![CDATA[<p>I tried below code in my ReportViewer page, but does not work.  Please help.  Thanks,</p>
<p>           foreach (RenderingExtension extension in ReportViewer1.ServerReport.ListRenderingExtensions())<br />
            {<br />
                if (extension.Name == &#8220;XML&#8221;)<br />
                {<br />
                    FieldInfo info = extension.GetType().GetField(&#8220;m_isVisible&#8221;, BindingFlags.NonPublic | BindingFlags.Instance);<br />
                    if (info != null)<br />
                    {<br />
                        info.SetValue(extension, false);<br />
                    }<br />
                }</p>
<p>            }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Giulliano Dias</title>
		<link>http://mikemason.ca/blog/2007/04/disabling-export-formats-in-reporting-services/comment-page-1/#comment-15258</link>
		<dc:creator>Giulliano Dias</dc:creator>
		<pubDate>Tue, 28 Apr 2009 16:53:00 +0000</pubDate>
		<guid isPermaLink="false">http://mikemason.ca/blog/?p=4#comment-15258</guid>
		<description>Mike,

   I worked with a version 9.0.0.0 and I found a lot of problems. I solved these problems with the code below:
public void DisableUnwantedExportFormats()
        {
            foreach (RenderingExtension extension in serverReport.ListRenderingExtensions())
            {
                if (extension.Name == “XML” &#124;&#124; extension.Name == “IMAGE” &#124;&#124; extension.Name == “MHTML”)
                {
                    ReflectivelySetVisibilityFalse(extension);                    
                }
            }
        }

        private void ReflectivelySetVisibilityFalse(RenderingExtension extension)
        {
            FieldInfo info = extension.GetType().GetField(&quot;m_isVisible&quot;,
                             BindingFlags.NonPublic &#124; BindingFlags.Instance);       

            if (info != null)
            {
                info.SetValue(extension, false);
            }
        }


// regards.</description>
		<content:encoded><![CDATA[<p>Mike,</p>
<p>   I worked with a version 9.0.0.0 and I found a lot of problems. I solved these problems with the code below:<br />
public void DisableUnwantedExportFormats()<br />
        {<br />
            foreach (RenderingExtension extension in serverReport.ListRenderingExtensions())<br />
            {<br />
                if (extension.Name == “XML” || extension.Name == “IMAGE” || extension.Name == “MHTML”)<br />
                {<br />
                    ReflectivelySetVisibilityFalse(extension);<br />
                }<br />
            }<br />
        }</p>
<p>        private void ReflectivelySetVisibilityFalse(RenderingExtension extension)<br />
        {<br />
            FieldInfo info = extension.GetType().GetField(&#8220;m_isVisible&#8221;,<br />
                             BindingFlags.NonPublic | BindingFlags.Instance);       </p>
<p>            if (info != null)<br />
            {<br />
                info.SetValue(extension, false);<br />
            }<br />
        }</p>
<p>// regards.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Svapneel</title>
		<link>http://mikemason.ca/blog/2007/04/disabling-export-formats-in-reporting-services/comment-page-1/#comment-9708</link>
		<dc:creator>Svapneel</dc:creator>
		<pubDate>Tue, 03 Feb 2009 14:27:56 +0000</pubDate>
		<guid isPermaLink="false">http://mikemason.ca/blog/?p=4#comment-9708</guid>
		<description>Hi,

Thanks it worked like magic. I was using version 8.0.0.0 of report viewr common and webforms and it worked.

To be honest I do not fully understand the solution but it works.

Thanks again.</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Thanks it worked like magic. I was using version 8.0.0.0 of report viewr common and webforms and it worked.</p>
<p>To be honest I do not fully understand the solution but it works.</p>
<p>Thanks again.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mike</title>
		<link>http://mikemason.ca/blog/2007/04/disabling-export-formats-in-reporting-services/comment-page-1/#comment-8967</link>
		<dc:creator>mike</dc:creator>
		<pubDate>Fri, 16 Jan 2009 16:33:19 +0000</pubDate>
		<guid isPermaLink="false">http://mikemason.ca/blog/?p=4#comment-8967</guid>
		<description>Hi Ravi,

Unfortunately this technique only works with Reporting Services 2005, I haven&#039;t updated it for 2008. If you wish to disable Excel export you can still do this across the entire Reporting Services server, but this will disable Excel for all reports on the server, not just a specific report.

You will need to modify the Render section in your Reporting Services configuration file. MSDN has more information here: http://msdn.microsoft.com/en-us/library/ms156281.aspx</description>
		<content:encoded><![CDATA[<p>Hi Ravi,</p>
<p>Unfortunately this technique only works with Reporting Services 2005, I haven&#8217;t updated it for 2008. If you wish to disable Excel export you can still do this across the entire Reporting Services server, but this will disable Excel for all reports on the server, not just a specific report.</p>
<p>You will need to modify the Render section in your Reporting Services configuration file. MSDN has more information here: <a href="http://msdn.microsoft.com/en-us/library/ms156281.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms156281.aspx</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ravi raiya</title>
		<link>http://mikemason.ca/blog/2007/04/disabling-export-formats-in-reporting-services/comment-page-1/#comment-8959</link>
		<dc:creator>ravi raiya</dc:creator>
		<pubDate>Fri, 16 Jan 2009 11:50:06 +0000</pubDate>
		<guid isPermaLink="false">http://mikemason.ca/blog/?p=4#comment-8959</guid>
		<description>hi dear,,,

i m using local report of microsoft report server in vs2008. i just want to ristrict user not to export data in excel. i tried it many ways but all fail can u help doing this........

need reply urgently...........

thanx in advance</description>
		<content:encoded><![CDATA[<p>hi dear,,,</p>
<p>i m using local report of microsoft report server in vs2008. i just want to ristrict user not to export data in excel. i tried it many ways but all fail can u help doing this&#8230;&#8230;..</p>
<p>need reply urgently&#8230;&#8230;&#8230;..</p>
<p>thanx in advance</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mike</title>
		<link>http://mikemason.ca/blog/2007/04/disabling-export-formats-in-reporting-services/comment-page-1/#comment-6136</link>
		<dc:creator>mike</dc:creator>
		<pubDate>Thu, 30 Oct 2008 18:42:28 +0000</pubDate>
		<guid isPermaLink="false">http://mikemason.ca/blog/?p=4#comment-6136</guid>
		<description>Hi Sunil. I haven&#039;t looked at RS 2008, but I&#039;m not surprised the internals have changed. Maybe there&#039;s now an official way to select export formats on a per-report basis.</description>
		<content:encoded><![CDATA[<p>Hi Sunil. I haven&#8217;t looked at RS 2008, but I&#8217;m not surprised the internals have changed. Maybe there&#8217;s now an official way to select export formats on a per-report basis.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
