我們在網站上使用了許多報告。在將某些報告導出爲PDF時,文件大小變大,服務器因加載而崩潰。所以,如果我只能針對某些有問題的報告禁用導出爲PDF選項,那就太好了。SSRS - 爲個別報告禁用導出選項(例如PDF)
那麼是否有辦法在報表查看器9.0(SSRS)中爲個別報表禁用某些導出選項(例如:導出爲PDF)?
謝謝。
我們在網站上使用了許多報告。在將某些報告導出爲PDF時,文件大小變大,服務器因加載而崩潰。所以,如果我只能針對某些有問題的報告禁用導出爲PDF選項,那就太好了。SSRS - 爲個別報告禁用導出選項(例如PDF)
那麼是否有辦法在報表查看器9.0(SSRS)中爲個別報表禁用某些導出選項(例如:導出爲PDF)?
謝謝。
可以在全局範圍隱藏在一個特定的配置文件在這裏PDF按鈕:
「安裝路徑\ Reporting Services的\的ReportServer \ rsreportserver.config」
有關詳細信息,已經有關於這個StackOverflow上的話題。
請更多的答案點擊這裏:ReportViewer - Hide PDF Export
我給這家
$(document).ready(function() {
var sel = $("select#ReportViewer2_ctl01_ctl05_ctl00");
sel.find("option[value='XML']").remove();
sel.find("option[value='CSV']").remove();
sel.find("option[value='IMAGE']").remove();
sel.find("option[value='MHTML']").remove();
sel.find("option[value='PDF']").remove();
sel.find("option[value='EXCEL']").remove();
});
這個問題可能在問題得到解答時發揮作用,但不在新版本的SSRS中。查看我的答案獲取更多信息。 – 2017-08-03 15:35:54
您可以使用Pre_render解決方案報告查看器中的事件。
protected void ReportViewer1_PreRender(object sender, EventArgs e)
{
DisableUnwantedExportFormat((ReportViewer)sender, "Excel");
DisableUnwantedExportFormat((ReportViewer)sender, "Word");
}
這個帖子看看
嗨shamcs,我會在哪裏放置上面的代碼。我不認爲它進入報告的自定義代碼部分 – 2014-10-29 09:28:46
@MarkOKeeffe您可以按照我在那裏給出的鏈接,在報告查看器控制器上,向事件OnPreRender添加操作。 – shamcs 2014-10-30 09:37:58
萬一別人說出聲之前在這裏或在相關報道:
的neatiest全球性解決方案是找到(我的程序位於:C:\ Program Files \ Microsoft SQL Server \ MSRS12.MSSQLSERVER \ Reporting Services \ ReportServer \ rsreportserver.config),請轉至xml鍵: 擴展>渲染,並在每個條目的末尾插入下面的屬性,你要隱藏:
可見= 「假」
例子:
<擴展名=「XML」Type =「Microsoft.ReportingServices.Rendering.DataRenderer.XmlDataReport,Microsoft.ReportingServices.DataRendering」Visible =「false」/>
或者把< - !和- >(HTML註釋標記)在入口的開始和結束。
對於個別報告,這些功能將會有所斬獲。
好簡潔的回答! – callisto 2016-09-09 06:10:06
我正在使用MvcReportViewer庫在我們的MVC應用程序中獲取SSRS的報告查看器。該庫不支持用戶控件生命週期事件,所以我無法使用shamcs提供的PreRender方法。由Ristanovic Marko描述的Javascript方法部分工作,但選擇器不適用於我們使用的SSRS版本,它需要將JQuery加載到IFrame中,並且它沒有描述只爲特定報告執行此操作的方法。以下是我想出了:
在我的ReportViewer部分,添加以下腳本塊:
var frame = $('#reportframe');
var src = frame.attr('src');
frame.attr('src', src + '?showAdditionalExports=' + @ViewBag.ShowExportsAttribute);
在ReportViewerWebForm.aspx,我添加了另一個腳本塊:
var urlParams = new URLSearchParams(location.search);
if (urlParams.get('showAdditionalExports') === 'true') {
document.addEventListener("DOMContentLoaded",
function() {
['Word', 'Excel'].map(function(title) {
var menuItem = document.querySelector("#ReportViewer1 a[title='" + title + "']")
.parentNode;
menuItem.parentNode
.removeChild(menuItem);
});
});
}
問題不是新的,但也許對於有同樣問題的人來說,我的答案也是有用的。在web.config
=>configuration
=>configSections
部分粘貼一個新的配置爲Telerik的報告,如果你沒有:
<section
name="Telerik.Reporting"
type="Telerik.Reporting.Configuration.ReportingConfigurationSection, Telerik.Reporting, Version=11.0.17.118, Culture=neutral, PublicKeyToken=a9d7983dfcc261be"
allowLocation="true"
allowDefinition="Everywhere"/>
使用您的優化版本Telerik的在version
屬性。你可以從Solution Explorer
=>your project name
=>References
=>TelerikReporting
=>Properties
,也找到了它,在<configrations>
體,貼:
<Telerik.Reporting>
<extensions>
<render>
<extension name="RTF" visible="false">
</extension>
<extension name="PDF" visible="false">
</extension>
<extension name="CSV" visible="false">
</extension>
<extension name="IMAGE" visible="false">
</extension>
<extension name="MHTML" visible="false">
</extension>
<extension name="XPS" visible="false">
</extension>
</render>
</extensions>
</Telerik.Reporting>
在上面的代碼我禁用任何類型的出口,除了Excel中。
謝謝。但是不能全局禁用所有報告的「導出爲PDF」?我們想要實現的目的是能夠禁止僅爲單個報告導出爲PDF。 – user1449265 2013-04-09 09:20:06
我的答案末尾的鏈接包含針對此特定問題的更多解決方案,而不會全局禁用PDF導出。 – dn7123 2013-04-12 07:47:56