找回密码
 立即注册

QQ登录

只需一步,快速开始

weijianxiong

论坛元老

19

主题

81

帖子

2万

积分

论坛元老

积分
20107

活字格认证

weijianxiong
论坛元老   /  发表于:2015-7-16 14:06  /   查看:4375  /  回复:4
:求大神怎样教我用Active report9怎样导出pdf

4 个回复

倒序浏览
frank.zhang
社区贡献组   /  发表于:2015-7-16 16:13:00
沙发
您好,
AR的报表分为RDL,页面报表和区域报表。
以应用最广泛的RDL报表为例,可以使用以下代码实现导出pdf
  1.         protected void btnPdf_Click(object sender, EventArgs e)
  2.         {
  3.             // Provide the page report you want to render.
  4.             string report = "rptInvoice";
  5.             GrapeCity.ActiveReports.PageReport _reportDef = new GrapeCity.ActiveReports.PageReport(new System.IO.FileInfo(Server.MapPath("~/Reports/" + report + ".rdlx")));
  6.             _reportDef.Report.DataSources[0].DataSourceReference = "";
  7.             _reportDef.Report.DataSources[0].ConnectionProperties.DataProvider = "OLEDB";
  8.             _reportDef.Report.DataSources[0].ConnectionProperties.ConnectString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};", Server.MapPath("~/Data/NWind_CHS.mdb"));
  9.             GrapeCity.ActiveReports.Document.PageDocument _reportRuntime = new GrapeCity.ActiveReports.Document.PageDocument(_reportDef);
  10.             // Create an output directory
  11.             System.IO.MemoryStream ms = new System.IO.MemoryStream();
  12.             // Provide settings for your rendering output.
  13.             GrapeCity.ActiveReports.Export.Pdf.Page.Settings pdfSetting = new
  14.             GrapeCity.ActiveReports.Export.Pdf.Page.Settings();
  15.             GrapeCity.ActiveReports.Extensibility.Rendering.ISettings setting = pdfSetting;
  16.             //Set the rendering extension and render the report.
  17.             GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension pdfRenderingExtension =
  18.             new GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension();
  19.             GrapeCity.ActiveReports.Rendering.IO.MemoryStreamProvider outputProvider = new GrapeCity.ActiveReports.Rendering.IO.MemoryStreamProvider();
  20.             _reportRuntime.Render(pdfRenderingExtension, outputProvider, pdfSetting);
  21.             Response.ContentType = "application/pdf";
  22.             Response.AddHeader("content-disposition", "inline;filename=客户订单.pdf");
  23.             outputProvider.GetPrimaryStream().OpenStream().CopyTo(ms);
  24.             Response.BinaryWrite(ms.ToArray());
  25.             Response.End();
  26.         }
复制代码

希望能够帮助到您。
回复 使用道具 举报
frank.zhang
社区贡献组   /  发表于:2015-7-24 09:18:00
板凳
您好,
距离这个问题的最后回复已经过去了一段时间,不知道这个问题您是否已经解决?
如果没有解决,欢迎跟贴接续讨论,如果已经解决请对本次服务进行评分。我们会认真对待你提出的宝贵意见,谢谢
回复 使用道具 举报
jishaojia
注册会员   /  发表于:2015-12-6 00:20:00
地板
回复 2楼frank.zhang的帖子

你好,我想问下我的是dataset数据集,怎么样赋值到报表文件上然后导出电子表格,或者是文档,或者是pdf
而不是例子里面这样的赋值。
  1. _reportDef.Report.DataSources[0].DataSourceReference = "";
  2.             _reportDef.Report.DataSources[0].ConnectionProperties.DataProvider = "OLEDB";
  3.             _reportDef.Report.DataSources[0].ConnectionProperties.ConnectString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};", Server.MapPath("~/Data/NWind_CHS.mdb"));
复制代码
回复 使用道具 举报
frank.zhang
社区贡献组   /  发表于:2015-12-7 10:09:00
5#
回复 4楼jishaojia的帖子

您好,

这个问题我们在http://gcdn.gcpowertools.com.cn/showtopic-19747.html
中继续讨论
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部