找回密码
 立即注册

QQ登录

只需一步,快速开始

Exep

注册会员

14

主题

57

帖子

157

积分

注册会员

积分
157

活字格认证

Exep
注册会员   /  发表于:2015-8-7 11:05  /   查看:4349  /  回复:3
请问如何能把一个查询出的dataset导出到pdf文件,谢谢

3 个回复

倒序浏览
frank.zhang
社区贡献组   /  发表于:2015-8-7 13:59:00
沙发
您好,
跟之前给导出的Excel的例子是一致的,改了相关导出PDF的方法。
  1.             GrapeCity.ActiveReports.PageReport _reportDef = new GrapeCity.ActiveReports.PageReport(new System.IO.FileInfo(Server.MapPath("~/Reports/" + report + ".rdlx")));
  2.             _reportDef.Report.DataSources[0].DataSourceReference = "";
  3.             _reportDef.Report.DataSources[0].ConnectionProperties.DataProvider = "OLEDB";
  4.             _reportDef.Report.DataSources[0].ConnectionProperties.ConnectString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};", Server.MapPath("~/Data/NWind_CHS.mdb"));

  5.             GrapeCity.ActiveReports.Document.PageDocument _reportRuntime = new GrapeCity.ActiveReports.Document.PageDocument(_reportDef);

  6.             // Create an output directory
  7.             System.IO.MemoryStream ms = new System.IO.MemoryStream();

  8.             // Provide settings for your rendering output.
  9.             GrapeCity.ActiveReports.Export.Pdf.Page.Settings pdfSetting = new
  10.             GrapeCity.ActiveReports.Export.Pdf.Page.Settings();
  11.             GrapeCity.ActiveReports.Extensibility.Rendering.ISettings setting = pdfSetting;
  12.             //Set the rendering extension and render the report.
  13.             GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension pdfRenderingExtension =
  14.             new GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension();
  15.             GrapeCity.ActiveReports.Rendering.IO.MemoryStreamProvider outputProvider = new GrapeCity.ActiveReports.Rendering.IO.MemoryStreamProvider();
  16.             _reportRuntime.Render(pdfRenderingExtension, outputProvider, pdfSetting);

  17.             Response.ContentType = "application/pdf";
  18.             Response.AddHeader("content-disposition", "attachment;filename=客户订单.pdf");
  19.             outputProvider.GetPrimaryStream().OpenStream().CopyTo(ms);
  20.             Response.BinaryWrite(ms.ToArray());
  21.             Response.End();
复制代码

评分

参与人数 1满意度 +5 收起 理由
sunshiqi + 5 这不错

查看全部评分

回复 使用道具 举报
Exep
注册会员   /  发表于:2015-8-7 14:01:00
板凳
好的  谢谢您的解答  如果有什么问题我还会继续请教
回复 使用道具 举报
frank.zhang
社区贡献组   /  发表于:2015-8-7 15:47:00
地板
好的,
没有问题。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部