找回密码
 立即注册

QQ登录

只需一步,快速开始

scchao1986

注册会员

9

主题

16

帖子

187

积分

注册会员

积分
187

活字格认证

scchao1986
注册会员   /  发表于:2015-3-25 17:04  /   查看:4649  /  回复:4
http://blog.gcpowertools.com.cn/post/2014/08/24/advanced-html-viewer-with-export-options.aspx
这个例子中
  1. protected void Page_Load(object sender, EventArgs e)
  2. {
  3.    if (Request["Task"] != null)
  4.    {
  5.       if (Request["Task"].ToString().Contains("Print"))
  6.       {
  7.          rptCustHTML rpt = new rptCustHTML();
  8.          try
  9.          {
  10.             rpt.Run(false);
  11.          }
  12.          catch (Exception eRunReport)
  13.          {
  14.             //If the report fails to run, report the error to the user
  15.             Response.Clear();
  16.             Response.Write("<h1>Error running report:</h1>");
  17.             Response.Write(eRunReport.ToString());
  18.             return;
  19.          }
  20.          //Buffer this page's output until the report output is ready.
  21.          Response.Buffer = true;
  22.   
  23.          //Clear any part of this page that might have already been buffered for output.
  24.          Response.ClearContent();
  25.   
  26.          //Clear any headers that might have already been buffered (such as the content
  27.          //type for an HTML page)
  28.          Response.ClearHeaders();
  29.   
  30.          //Tell the browser and the "network" that the resulting data of this page should
  31.          //be cached since this could be a dynamic report that changes upon each request.
  32.          Response.Cache.SetCacheability(HttpCacheability.NoCache);
  33.   
  34.          //Tell the browser this is an HTML document so it will use an appropriate viewer.
  35.          Response.ContentType = "text/html";
  36.   
  37.          //Create the HTML export object
  38.          GrapeCity.ActiveReports.Export.Html.Section.HtmlExport htmlExport1 = new GrapeCity.ActiveReports.Export.Html.Section.HtmlExport();
  39.   
  40.          //Export the report to HTML in this session's webcache
  41.          MyCustomHtmlOutputter outputter = new MyCustomHtmlOutputter(this.Context);
  42.          htmlExport1.Export(rpt.Document, outputter, "");
  43.          Response.Redirect("ReportOutput" + "/" + System.IO.Path.GetFileName(outputter.mainPage));
  44.       }
  45.    }
  46. }
复制代码


我看例子里面自己用程序生成了一个SectionReport,那如果是一个现成的带参数的pagereport又怎么处理呢?
还有,可不可以使用前台htmlExport然后进入打印页面?请技术支持的老师帮忙看看

4 个回复

倒序浏览
frank.zhang
社区贡献组   /  发表于:2015-3-25 17:47:00
沙发
您好,
您的问题我们已经收到,明天继续调查。
回复 使用道具 举报
frank.zhang
社区贡献组   /  发表于:2015-3-26 17:19:00
板凳
您好,
RDL的思路是取到view,然后在直接操作打印。以下代码是基于您在帖子中提到的那篇博客的第二个例子进行功能的增加。
参考代码
  1. var printBtn = '<span><input id="btnPrint" type="Button" value="Print" onclick="print()"/></span>';

  2.         $(document).ready(function () {
  3.             var selectedValue = $("#fldReportName").val();
  4.             if (selectedValue !== "") {
  5.                 setTimeout(function () {
  6.                     $("#ReportSelect").val(selectedValue);
  7.                 }, 100);
  8.             }
  9.             var toolbar = $('#WebViewer1').find('.arvToolBar');
  10.             toolbar.append(reportSelect);
  11.             toolbar.append(exportSelect);
  12.             toolbar.append(printBtn);
  13.             var viewModel = GetViewModel("WebViewer1");

  14.             //Force a postback upon report selection
  15.             $("#ReportSelect").change(function (e, args) {
  16.                 var reportName = this.value;
  17.                 $("#fldReportName").val(reportName);
  18.                 ForcePostBack();
  19.                 this.value = $("#fldReportName").val();
  20.             });

  21.             function print() {
  22.                 viewModel.Print();
  23.             };
复制代码

评分

参与人数 1满意度 +5 收起 理由
scchao1986 + 5 多谢了,我再试试

查看全部评分

回复 使用道具 举报
scchao1986
注册会员   /  发表于:2015-3-27 11:58:00
地板
回复 3楼frank.zhang的帖子

多谢了,我再试试
回复 使用道具 举报
frank.zhang
社区贡献组   /  发表于:2015-3-27 15:01:00
5#
我们正在举行用户满意度调查(点击填写)活动,诚挚邀请您参加。您只需回答链接中的几个问题,就可以获得 1000 GCDN 金币用于兑换礼品,更有机会领取50元京东购物卡。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部