Reputation: 3427
For each report I'd like to be able to specify either which export options are supported or which are not supported. There's a similar question here: SSRS - Disabling export options (eg. PDF) for individual reports
But those answers are either out of date or apply globally. Is there an option I can set within the RDL to limit export options to only excel, for example?
The client is running SSRS 2012.
Upvotes: 1
Views: 1158
Reputation: 1008
I recently did this on my system (SSRS 2016) based on this blog post. The post states that it is for 2012/2014, so it should work for your case as well. The change is technically applied globally in that it is not specifically applied in the individual RDL, but you can restrict the export options for individual reports using this method.
To summarize, I added the following to my ReportViewer.aspx file:
<script language = "Javascript">
// Disable Export Options Per Report
//
// This JavaScript is used to disable export options in reports. In order to disable an option add another call to RemoveExportOptions
//
// Example: RemoveExportOption("/ReportProject1/Report1", "Excel");
//
// In order to implement this, just save the script in the Report.apsx page of the SSRS server. No reboot or restart is needed. It will just work :)
//
var timer;
var dueTime=0
var options = {
"excel":"Excel",
"xml":"XML file with report data",
"csv":"CSV (comma delimited)",
"pdf":"PDF",
"mhtml":"MHTML (web archive)",
"tiff":"TIFF file",
"word":"Word"
}
function RemoveCTLExportFormats(format)
{
dueTime += 50;
if(dueTime > 30000)
{
clearTimeout(timer);
return;
}
if (format.toLowerCase() == "all")
{
var obj=document.getElementsByTagName("table");
for(var i=0;i<obj.length;i++)
{
if (obj[i].title == "Export drop down menu")
{
obj[i].style.display="None"
}
}
}
else
{
var obj=document.getElementsByTagName("A");
for(var i=0;i<obj.length;i++)
{
if (obj[i].title == options[format])
{
obj[i].style.display="None"
}
}
}
timer=setTimeout("RemoveCTLExportFormats('" + format + "')",50);
}
function RemoveExportOption(report, format)
{
url = unescape(location.href).replace("&","").replace("+","")
if (url.indexOf(report) != -1)
{
timer2=setTimeout("RemoveCTLExportFormats('" + format.toLowerCase() + "')",50);
}
else
{
return;
}
}
// List the reports with the options you want removed. Leave special characters and spaces out of the report path:
//
// Example: /My New Report/Report Test 1 => /MyNewReport/ReportTest1
//
// If you want to remove multiple options, then list the report multiple times. "ALL" removes all the export options
//
// Options are (not case sensitive):
//
// ALL - Removes all the options
// Excel - Removes Excel
// XML - Removes XML file with report data
// CSV - Removes CSV (comma delimited)
// PDF - Removes PDF
// MHTML - Removes MHTML (web archive)
// TIFF - Removes TIFF file
// Word - Removes Word
//
RemoveExportOption("/Your/Report/Path/Here", "All");
RemoveExportOption("/Another/Report/RemoveWord", "Word");
</script>
I have not worked with SSRS 2012 but based on the blog post, that file might be called Report.aspx on 2012. You will want to of course change the report paths on those last 2 lines of the script to point to the report in question that needs exporting restricted.
Upvotes: 1