找回密码
 立即注册

QQ登录

只需一步,快速开始

fhd2589

银牌会员

3

主题

7

帖子

2129

积分

银牌会员

积分
2129

活字格认证

最新发帖
fhd2589
银牌会员   /  发表于:2014-10-17 13:45  /   查看:4981  /  回复:1
在web程序使用页面报表导出pdf,数据源用DATATABLE绑定,不使用viewer控件显示,通过按钮直接导出pdf。
我做了个例子,但报错:'In order to use an object with the ObjectDataSource it must support the IEnumerable interface

代码如下:

GrapeCity.ActiveReports.PageReport report = new GrapeCity.ActiveReports.PageReport(new System.IO.FileInfo(Server.MapPath(&quotageReport1.rdlx")));
            GrapeCity.ActiveReports.Document.PageDocument _reportRuntime = new GrapeCity.ActiveReports.Document.PageDocument(report);
            //绑定数据源datatable
            _reportRuntime.LocateDataSource += new GrapeCity.ActiveReports.LocateDataSourceEventHandler(document_LocateDataSource);
      

            //导出pdf
            GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension _renderingExtension = new GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension();
            GrapeCity.ActiveReports.Rendering.IO.MemoryStreamProvider _provider = new GrapeCity.ActiveReports.Rendering.IO.MemoryStreamProvider();
            _reportRuntime.Render(_renderingExtension, _provider); //此处报错
            Response.ContentType = "application/pdf";
            Response.AddHeader("content-disposition", Server.UrlPathEncode("attachment;filename=客户订单.pdf"));
            System.IO.MemoryStream ms = new System.IO.MemoryStream();
            _provider.GetPrimaryStream().OpenStream().CopyTo(ms);
            Response.BinaryWrite(ms.ToArray());
            Response.End();


请帮忙

1 个回复

倒序浏览
iceman
社区贡献组   /  发表于:2014-10-17 19:06:00
沙发
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部