我已经在我的aspx中嵌入了Microsoft.Reporting.WebForms.ReportViewer控件。我的网站在mysite.com上工作。当尝试导出报表时,有一个新的黑色窗口打开,上面有address mysite.com/Reserved.ReportViewerWebControl.axd... 。它工作正常。但是..。我想通过我的代理人传递那个斧头。我的意思是,我想强制导出使用url myproxy.mysite.com/Reserved.ReportViewerWebControl.axd...,它会将请求重定向回我注意到的mysite.com/Reserved.ReportViewerWebControl.axd...,这个链接是在js中构建的(这个链接包含在axd中):
ExportReport: function(format)
{
if (this.ExportUrlBase == null)
return false;
window.open(this.ExportUrlBase + encodeURIComponent(format), "_blank");
return true;
}, 到axd的url存储在ExportUrlBase中。如何将其更改为代理服务器url?
发布于 2014-10-13 17:28:23
可以在javascript中修改ExportUrlBase字段。报表本身存储在页面的某个占位符中,一旦发现可以在其上创建调用_getInternalViewer()函数来访问ExportUrlBase。请看以下代码:
function ModifyExportUrlBase()
{
var rv = null;
var r = null;
try
{
// get the report viewer
rv = this.$find("ctl31");
r = rv._getInternalViewer();
}
catch(err)
{
console.log(err)
setTimeout(ModifyExportFileName, 2000)
return;
}
if(r == null)
{
setTimeout(ModifyExportFileName, 2000);
return;
}
else{
r.ExportUrlBase = "/yourproxypath" + r.ExportUrlBase
}
}
ModifyExportUrlBase();超时是必要的,因为报告是异步接收的,而且只有在报表完全加载之后才能工作。
使用firebug上的ctl31元素特性来检查实际的下载链接,就会有一个onclick方法,它利用页面上报告的ID。我看过的其他网站表示,如果您使用的是动态客户关系管理,它可能会"reportViewer“。找到答案的最简单方法就是使用firebug或开发工具来检查它。
不幸的是,这并不能完全解决您的问题,因为ExportUrlBase没有存储整个URL,只是相对于域的URL,即,ExportUrlBase =“Reserved.ReportViewerWebControl.axd.”不是“www.yoursite.com/订票.Reserved.ReportViewer.”但是,一旦您可以更改它,您就可以使用新的配置在inetpub文件夹中创建一个目录,并通过该文件夹重定向链接以使用该配置。
资料来源:
http://reportsyouneed.com/ssrs-adding-date-to-exported-filenames/
发布于 2017-05-01 18:40:04
您可以尝试替换ExportReports()函数的行为:
Microsoft.Reporting.WebFormsClient._InternalReportViewer.prototype.ExportReport =
function(){ return "/proxypath" + this.ExportUrlBase }
window.open(
$find('ReportViewerControl').exportReport() + encodeURIComponent('CSV'),
"_blank"
);https://stackoverflow.com/questions/22763513
复制相似问题