报了一个异常,没有数据,这里我使用的是DataTable作为数据
No data has been set. Please specify either a DataSet or a DataView to use
说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.InvalidOperationException: No data has been set. Please specify either a DataSet or a DataView to use
源错误:
行 84: GrapeCity.ActiveReports.Rendering.IO.MemoryStreamProvider _provider = new GrapeCity.ActiveReports.Rendering.IO.MemoryStreamProvider();
行 85: GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension _renderingExtension = new GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension();
行 86: _reportRuntime.Render(_renderingExtension, _provider);
行 87: System.IO.MemoryStream ms = new System.IO.MemoryStream();
行 88:
code:
PageReport report = null;
report = new PageReport(new FileInfo(Server.MapPath("~/Reports/" + repreport.RepReportTemplate.FileName)));
((PageReport)(report)).Document.LocateDataSource += Document_LocateDataSource;
report.Report.Code = "ublic Dim unit As String = \"MMM\"";
ViewBag.Report = report;
GrapeCity.ActiveReports.Document.PageDocument _reportRuntime = new GrapeCity.ActiveReports.Document.PageDocument(report);
GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension pdfext = new PdfRenderingExtension();
GrapeCity.ActiveReports.Rendering.IO.MemoryStreamProvider _provider = new GrapeCity.ActiveReports.Rendering.IO.MemoryStreamProvider();
GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension _renderingExtension = new GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension();
_reportRuntime.Render(_renderingExtension, _provider);
System.IO.MemoryStream ms = new System.IO.MemoryStream();
_provider.GetPrimaryStream().OpenStream().CopyTo(ms);
FileStream fs = new FileStream("d:\\reporta.pdf", FileMode.CreateNew);
fs.Write(ms.GetBuffer(),0,ms.GetBuffer().Length);
fs.Close(); |