在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("ageReport1.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();
请帮忙 |
|