Limit report from being exported to excel
We have a report that we do not want to be able to be exported to excel. Is there a way, just on one report to limit the types it is exported toDBA
October 12th, 2009 9:42pm
There is not a way to disable excel rendering (or any specific rendering format) for a single report. You are able to disable excel rendering for the server, but that would disable it for all reports on that server.
Pete Browning
SQL Server Reporting Services
This posting is provided AS IS with no warranties, and confers no rights.
Free Windows Admin Tool Kit Click here and download it now
October 13th, 2009 2:57am
Hi DBAMT,
As Pete mentioned, by default, we can only disable Excel Render Extension for the server.
However, a possible workaround to disable Excel Render Extension for a simply report is using JavaScript to remove the Excel option from the export formats list.
Please follow these steps to do so:
1. Go to the physical folder of the Report Manager.
By default, the folder is:
C:\Program Files\Microsoft SQL Server\MSSQL.3\Reporting Services\ReportManager
2. Please open the folder “Pages”
3. Open the file “Report.aspx” with notepad.
4. Embed the following JavaScript at the end of the file.
<script language = "Javascript">
//javascript: get parameter from URL
function getParameter(paraStr, url)
{
var result = "";
//get all parameters from the URL
var str = "&" + url.split("?")[1];
var paraName = paraStr + "=";
//check if the required parameter exist
if(str.indexOf("&"+paraName)!=-1)
{
//if "&" is at the end of the required parameter
if(str.substring(str.indexOf(paraName),str.length).indexOf("&")!=-1)
{
//get the end string
var TmpStr=str.substring(str.indexOf(paraName),str.length);
//get the value.
result=unescape(TmpStr.substr(TmpStr.indexOf(paraName) + paraName.length,TmpStr.indexOf("&")-TmpStr.indexOf(paraName) -
paraName.length));
}
else
{
result=unescape(str.substring(str.indexOf(paraName) + paraName.length,str.length));
}
}
else
{
result="Null";
}
return (result.replace("&",""));
}
var timer2;
var dueTime2=0
function RemoveCTLExportFormats(format)
{
dueTime2 += 50;
if(dueTime2 > 30000)
{
clearTimeout(timer2);
return;
}
var obj=document.getElementsByTagName("Select");
for(var i=0;i<obj.length;i++)
{
if (obj[i].title == "Export Formats")
{
var k = -1;
for(var j = 0; j < obj[i].length; j ++)
{
if(obj[i].options[j].value.toLowerCase() == format.toLowerCase())
{
k = j;
obj[i].options.remove(k);
clearTimeout(timer2);
return;
}
}
}
}
timer2=setTimeout("RemoveCTLExportFormats('" + format + "')",50);
}
function RemoveOption(report, format)
{
if(getParameter("ItemPath", location.href).toLowerCase() == report.toLowerCase())
{
timer2=setTimeout("RemoveCTLExportFormats('" + format + "')",50);
}
else
{
return;
}
}
RemoveOption("/ReportSamples/10000rows", "Excel");
</script>
To enable the function, please pass in the “report path”, and the format in the method RemoveOption.
Sample: RemoveOption("/ReportSamples/report1", "Excel");
Please feel free to ask if you have any more questions.
Thanks,
Jin ChenJin Chen - MSFT
October 14th, 2009 8:21am
sir i am Adnan i want to restrict export options i have SPS 2007 and Reporting Services 2008 and in Sharepoint Integrated Mode.One of the report is employee time attendance sheet.rdl i dont want that user will able to export it to any other format except pdf how it is possible please guid me , i also write this function as it is described and tell me one more thing that in my case
i have these steps to do:
1. Go to the physical folder of the Report Manager.
By default, the folder is:
C:\Program Files\Microsoft SQL Server\MSRS10.MSSQLSERVER\Reporting Services\ReportManager
2. open the folder “Pages”
3. Open the file “Report.aspx” with notepad.
4. Embed the following JavaScript at the end of the file.but i could not get that how to To enable the function, please pass in the “report path”, and the format in the method RemoveOption. // i did not get this please guid
Sample: RemoveOption("/ReportSamples/report1", "Excel");
Free Windows Admin Tool Kit Click here and download it now
March 13th, 2010 6:37pm
This might work fine with web version of reportviewer but how do i accomplish this for windows version of reportviewer. I am facing a problem in 2010 reportviewer wherein I can not export to word (works fine for excel and pdf) if i have "Go to report".
How will I disable export to Word alone??? I know this is a known issue but there must be a work around
Also, the header repeater columns wont work in 2010 if the report spans more than one page. I have to do it either VS 2005/2008 and then convert it in 2010.
November 24th, 2010 8:24am
Hi Jin Chen,
This was really useful code. The only catch is that in your code it does not accept report names with spaces. When I removed the spaces from my report name it worked brill.
Thanks Again for the code, this is really useful when we need to restrict some reports which cause issues while exporting to excel. I have not tried it yet but can I apply it to multiple reports?
Regards,
Vikram Kansal
Free Windows Admin Tool Kit Click here and download it now
January 26th, 2011 1:20pm
Yup just checked accepts multiple reports as well. Only Spaces is the issue.
Also Can you let me know what needs to be done to restrict Excel in the Report Viewer Control?
January 26th, 2011 1:27pm
Hi All,
I just followed the steps Jin Chen proposed on a SQL 2008 R2 report server, unfortunately without any succes. Did any of you try that ?
Your feedback will be appreciated,
Cees
Please remember to mark replies as answers or at least vote helpfull if they help and unmark them if they provide no help.
Free Windows Admin Tool Kit Click here and download it now
February 22nd, 2011 5:11am