Chrome 和 Firefox 中的 SSRS 打印按钮
我在 SSRS 2005 中有报告。我正在使用远程报告。在 IE 中,会显示打印按钮,但在 Firefox 和 Chrome 中,不会显示打印按钮。
我的报告显示在 jquery UI 对话框中,因此我不能只执行 window.print。我的报告在模态中渲染得很好。
我需要能够以与在控件内完成的方式相同的方式向报表查看器发出打印命令,但仅限于 Firefox 和 Chrome。
我深入研究了报告查看器的标记,并找到了这段代码。我尝试将其手动注入到报告查看器中,但没有成功。
<table id="reportViewer_ctl01_ctl07_ctl00_ctl00" onclick="document.getElementById('reportViewer').ClientController.LoadPrintControl();return false;" onmouseover="this.Controller.OnHover();" onmouseout="this.Controller.OnNormal();" title="Print" style="display:none;">
<script type="text/javascript">
document.getElementById('reportViewer_ctl01_ctl07_ctl00_ctl00').Controller = new ReportViewerHoverButton("reportViewer_ctl01_ctl07_ctl00_ctl00", false, "", "", "", "#ECE9D8", "#DDEEF7", "#99BBE2", "1px #ECE9D8 Solid", "1px #336699 Solid", "1px #336699 Solid");
</script><tr>
<td><input type="image" name="reportViewer$ctl01$ctl07$ctl00$ctl00$ctl00" title="Print" src="/Reserved.ReportViewerWebControl.axd?OpType=Resource&Version=9.0.30729.4402&Name=Microsoft.Reporting.WebForms.Icons.Print.gif" alt="Print" style="height:16px;width:16px;padding:2px;" /></td>
</tr>
</table>
有什么想法吗?
I have reports in SSRS 2005. I am using remote reports. In IE, the print button shows, but in Firefox and Chrome, the print button does not show.
My reports are shown in jquery UI dialogs, so I cannot just do a window.print. My reports render just fine within the modals.
I need to be able to issue a print command to the reportviewer the same way it is done from within the control, but only in firefox and chrome.
I dug into the markup for the report viewer, and found this code. I tried to manually inject it into the reportviewer with no success.
<table id="reportViewer_ctl01_ctl07_ctl00_ctl00" onclick="document.getElementById('reportViewer').ClientController.LoadPrintControl();return false;" onmouseover="this.Controller.OnHover();" onmouseout="this.Controller.OnNormal();" title="Print" style="display:none;">
<script type="text/javascript">
document.getElementById('reportViewer_ctl01_ctl07_ctl00_ctl00').Controller = new ReportViewerHoverButton("reportViewer_ctl01_ctl07_ctl00_ctl00", false, "", "", "", "#ECE9D8", "#DDEEF7", "#99BBE2", "1px #ECE9D8 Solid", "1px #336699 Solid", "1px #336699 Solid");
</script><tr>
<td><input type="image" name="reportViewer$ctl01$ctl07$ctl00$ctl00$ctl00" title="Print" src="/Reserved.ReportViewerWebControl.axd?OpType=Resource&Version=9.0.30729.4402&Name=Microsoft.Reporting.WebForms.Icons.Print.gif" alt="Print" style="height:16px;width:16px;padding:2px;" /></td>
</tr>
</table>
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
以下是我创建一个伪打印按钮的方法,该按钮将 Internet Explorer 中的报表查看器的打印功能模拟到其他浏览器。
请注意,下面的解决方案需要 JQuery。无需安装 ActiveX。
以下是步骤。
步骤 1. 在报表查看器所在的页面中添加打印按钮。
请务必将版本号更改为您的 RS 版本。如果您在使用 html 代码时遇到问题,可以使用 Internet Explorer 打开该页面并检查打印元素并复制它。
第 2 步。 添加将在其中呈现 PDF 的 div。
第 3 步。 添加脚本。
代码说明:
首先我们创建了一个变量来检测浏览器是否是IE。
通过使用 Reserve.ReportViewerWebControl.axd 中的 _getInternalViewer() 方法,我们可以请求 PDF 版本的报告作为请求,该请求最初是在单击导出按钮时检索的。
然后,我们将 contentDisposition 变量指定为“AlwaysInline”,因为我们希望以 PDF 形式请求报告,而不是作为附件,而是作为我们可以在 html 元素中呈现的 PDF。
https://msdn.microsoft.com/en -us/library/microsoft.reporting.webforms.reportviewer.exportcontentdisposition.aspx
src_new 变量用我们的新请求“AlwaysInline”替换默认的 EXPORT 按钮内容处置请求(默认设置为 AlwaysAttachment)。
接下来,我们将 iframe 的 src 设置为新的 url,加载后,将以 PDF 形式显示来自 reportviewer 的报告。
iframe 中的链接命令包括隐藏 pdf 元素、渲染它以及在加载完 pdf 后立即打印它。
结束语
我希望有人会发现这段代码有用,因为我很难在网上找到一个像样的解决方案,这是我在做了一些研究后想到的。
Here's what I did to create a pseudo print button which emulates the print function of Report Viewer in Internet Explorer to other browsers.
Please take note that the solution below requires JQuery. No ActiveX installation is necessary.
Here are the steps.
Step 1. Add the print button in your page where the report viewer is situated.
Be sure to change the Version number to your RS version. If you're having trouble with the html code, you can open the page with internet explorer and inspect the print element and copy it.
Step 2. Add a div where your PDF will be rendered.
Step 3. Add the script.
Code explanation :
First we created a variable which detects if the browser is IE or not.
By using the _getInternalViewer() method in Reserved.ReportViewerWebControl.axd we can request a PDF version of the report as a request which is originally retrieved upon clicking the export button.
We then assigned a contentDisposition variable as 'AlwaysInline' because we want to request the report as a PDF, not as an attachment but as a PDF that we can render in an html element.
https://msdn.microsoft.com/en-us/library/microsoft.reporting.webforms.reportviewer.exportcontentdisposition.aspx
The src_new variable replaces the default EXPORT button content disposition request (which is set to AlwaysAttachment by default) with our new request 'AlwaysInline'.
Next, we then set the src of the iframe to our new url which when loaded, will reveal our report from reportviewer as PDF.
The chained commands in the iframe includes hiding the pdf element, rendering it and printing it right away after it finishes loading the pdf.
Ending remarks
I hope that someone will find this code useful because I had a hard time finding a decent solution online and this is what I came up with after doing some research.
不幸的是,除 IE 之外的浏览器不支持打印按钮。
我认为您已经意识到这一点并采取了解决方法,但我们还没有拿出一个像样的解决方案。虽然我们的大多数用户更喜欢直接从 Excel 打印,所以我们允许他们导出文件,然后进行打印。
这个问题将是一个很好的链接:
SQL Reporting Services - Print Mozilla 中未显示按钮
Unfortunately the print button is not supported in browsers other than IE.
I think you realise this and did a workaround, we have yet to come up with a decent solution as well. Although most of our users prefer printing from Excel directly, so we allow them to export the file which they then do the printing.
This SO question would be a good link:
SQL Reporting Services - Print Button not shown in Mozilla
请查找 SSRS 报告的代码,该报告具有适用于 Firefox 和 Chrome 的打印图标和打印功能:
Please find the code for SSRS report that has Print Icon with Printing functionality for Firefox and Chrome:
我对上述内容做了一些更改,它在 Chrome 和 Firefox 中都很适合我。
I made some changes with regards to the above and it works well for me in both Chrome and Firefox.
我对上述内容做了一些更改,它在 Chrome 和 Edge 中都很适合我。
I made some changes with regards to the above and it works well for me in both Chrome and Edge.