I make use of a ReportView component in a VB.Net 2005 app. How can I disable the PDF export functionality, only keeping the MS Excel format?
I had the same problem. I could get the unwanted export options to hide when the report rendered, but it didn't work in the case of a drillthrough report. The following code worked for both the parent and drillthrough reports, using a LocalReport:
private void SuppressExportButton(ReportViewer rv, string optionToSuppress)
{
var reList = rv.LocalReport.ListRenderingExtensions();
foreach (var re in reList)
{
if (re.Name.Trim().ToUpper() == optionToSuppress.Trim().ToUpper()) // Hide the option
{
re.GetType().GetField("m_isVisible", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(re, false);
}
}
}
The trick is to call the method from the page PreRender method:
protected void Page_PreRender(object sender, System.EventArgs e)
{
SuppressExportButton(rvMain, "PDF");
SuppressExportButton(rvMain, "Word");
}