找回密码
 立即注册

QQ登录

只需一步,快速开始

yy

注册会员

2

主题

18

帖子

116

积分

注册会员

积分
116

活字格认证元老葡萄

最新发帖
yy
注册会员   /  发表于:2015-4-3 16:38  /   查看:14170  /  回复:21
演示的工具栏上有一个"导出报表"的按钮,但我在VB.NET中引用的Viewer没有这个按钮,
请问怎样可以把它显示出来?

21 个回复

倒序浏览
frank.zhang
社区贡献组   /  发表于:2015-4-3 18:17:00
沙发
您好,
这是一个自定义的按钮。需要增加前端代码。
  1.     <script src="http://code.jquery.com/jquery-1.11.1.min.js" type="text/javascript"></script>
  2.     <script language="javascript" type="text/javascript">
  3.         function ForcePostBack() {
  4.             form1.submit();
  5.         }
  6.         function printreport() {
  7.             viewModel.Print();
  8.         }
  9.         var reportSelect = '<select id="ReportSelect" style="width:150px"><option selected disabled>Choose Report</option><option value="SectionReport1">SectionReport1</option><option value="SectionReport2">SectionReport2</option><option value="RdlReport1">RdlReport1</option></select>';
  10.         var exportSelect = '<select id="ExportSelect" style="width:80px"><option selected disabled>Export</option><option value="PDF" style="background: url(images/pdf.png) right no-repeat; width: 50px">PDF</option><option value="Excel" style="background: url(images/Excel.gif) right no-repeat; width: 50px">Excel</option></select>';
  11.         var printBtn = '<span><input id="btnPrint" type="Button" value="Print" onclick="print()"/></span>';
  12.         $(document).ready(function () {
  13.             var selectedValue = $("#fldReportName").val();
  14.             if (selectedValue !== "") {
  15.                 setTimeout(function () {
  16.                     $("#ReportSelect").val(selectedValue);
  17.                 }, 100);
  18.             }
  19.             var toolbar = $('#WebViewer1').find('.arvToolBar');
  20.             toolbar.append(reportSelect);
  21.             toolbar.append(exportSelect);
  22.             toolbar.append(printBtn);
  23.             var viewModel = GetViewModel("WebViewer1");
  24.             //Force a postback upon report selection
  25.             $("#ReportSelect").change(function (e, args) {
  26.                 var reportName = this.value;
  27.                 $("#fldReportName").val(reportName);
  28.                 ForcePostBack();
  29.                 this.value = $("#fldReportName").val();
  30.             });
  31.             function print() {
  32.                 viewModel.Print();
  33.             };
  34.             //Check the selected value in DropDown and Export
  35.             $("#ExportSelect").change(function (e, args) {
  36.                 var valueSelected = this.value;
  37.                 if (viewModel.PageLoaded()) {
  38.                     switch (valueSelected) {
  39.                         case "PDF":
  40.                             viewModel.Export(ExportType.Pdf, function (uri) {
  41.                                 window.location = uri;
  42.                             }, true);
  43.                             break;
  44.                         case "Excel":
  45.                             viewModel.Export(ExportType.Xls, function (uri) {
  46.                                 window.location = uri;
  47.                             }, true);
  48.                             break;
  49.                     }
  50.                 }
  51.             });
  52.         });
  53.     </script>
复制代码
回复 使用道具 举报
yy
注册会员   /  发表于:2015-4-3 19:18:00
板凳
谢谢!我先试试看.
回复 使用道具 举报
frank.zhang
社区贡献组   /  发表于:2015-4-7 08:59:00
地板
回复 使用道具 举报
yy
注册会员   /  发表于:2015-4-10 14:18:00
5#
你好!我的编程环境是VS2010,VB.NET开发的系统,CS架构,目前用Viewer来显示打印报表,请问是否有相关的参考,谢谢!
回复 使用道具 举报
frank.zhang
社区贡献组   /  发表于:2015-4-10 17:05:00
6#
您好,
您的项目是CS架构,是winform还是WPF。展现报表的viewer控件,有直接打印的按钮。自定义的打印时,viewer控件有print的方法。您可以先尝试一下。
回复 使用道具 举报
yy
注册会员   /  发表于:2015-4-10 17:59:00
7#
是winform,创建好窗体和View控件,所有报表通过这个窗体装载显示
      Dim cn As New SqlConnection(sysArCnnString)
      Dim cmd As New SqlCommand(sysArSqls)
      Dim rd As SqlDataReader
      cmd.Connection=cn
      cn.Open()
      rd=cmd.ExecuteReader()
      objARrpt.DataSource=rd
      Viewer1.LoadDocument(objARrpt)
      Viewer1.Width=Me.Width -(Viewer1.Top*2)
      Viewer1.Height=Me.Height-(Viewer1.Left*2)
用户直接用viewer的工具栏提供的按钮操作,按下打印按钮就调出Windows的打印对话框了,不太明白怎么可以自定义,望指点,谢谢!
回复 使用道具 举报
frank.zhang
社区贡献组   /  发表于:2015-4-10 18:09:00
8#
您好,
可以在winform新建一个button,触发一个方法,在这个方法中调用Viewer1的print方法。
回复 使用道具 举报
yy
注册会员   /  发表于:2015-4-11 11:21:00
9#
试了下,有点摸不着头脑,可否给段调用代码参考,谢谢了!
回复 使用道具 举报
frank.zhang
社区贡献组   /  发表于:2015-4-13 08:55:00
10#
您好,
您方便上传你现在运行的代码吗?我们可以在这个基础上讨论,会比较有效率。
回复 使用道具 举报
123下一页
您需要登录后才可以回帖 登录 | 立即注册
返回顶部