本帖最后由 gotoStudy 于 2016-4-7 11:10 编辑
i5,8G PC主机,VS2015+MVC,
导出数据57页,(总共3371条数据,每条包含16列)数据库源是存储过程取出来的,直接在数据库执行存储过程时间<1ms,报表显示在页面的速度大概在4s左右,还有报表时进行了分组显示的,列父分组大概是8列,子分组大概是2列,主要代码如下
-
- System.IO.MemoryStream ms = new System.IO.MemoryStream();//存储返回的文件流
- PageReport report = new PageReport(new FileInfo(Server.MapPath(filename)));
- report.Report.ReportParameters[0].DefaultValue.Values.Add(examIds);
- GrapeCity.ActiveReports.Document.PageDocument _reportRuntime = new GrapeCity.ActiveReports.Document.PageDocument(report);
- GrapeCity.ActiveReports.Rendering.IO.MemoryStreamProvider _provider = new GrapeCity.ActiveReports.Rendering.IO.MemoryStreamProvider();
- switch (exporttype)
- {
- case 1://导出Pdf
- GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension _renderingExtension = new GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension();
- _reportRuntime.Render(_renderingExtension, _provider);
- contentType = "application/pdf";
- fileShuffix = ".pdf";
- break;
- case 2:////导出Excel
- //GrapeCity.ActiveReports.Export.Excel.Page.ExcelTransformationDevice _renderingExtentionExcel = new GrapeCity.ActiveReports.Export.Excel.Page.ExcelTransformationDevice();
- GrapeCity.ActiveReports.Export.Excel.Page.ExcelRenderingExtension _renderingExtentionExcel = new GrapeCity.ActiveReports.Export.Excel.Page.ExcelRenderingExtension();
- GrapeCity.ActiveReports.Export.Excel.Page.Settings s = new GrapeCity.ActiveReports.Export.Excel.Page.Settings();
- GrapeCity.ActiveReports.Export.Excel.Page.ExcelRenderingExtensionSettings
- excelSetting = new GrapeCity.ActiveReports.Export.Excel.Page.ExcelRenderingExtensionSettings();
- excelSetting.FileFormat = GrapeCity.ActiveReports.Export.Excel.Page.FileFormat.Xls;
- GrapeCity.ActiveReports.Extensibility.Rendering.ISettings setting = excelSetting;
- excelSetting.MultiSheet = false;
- excelSetting.Pagination = false;
- _reportRuntime.Render(_renderingExtentionExcel,_provider, excelSetting.GetSettings());
- contentType = "application/vnd.ms-excel";
- fileShuffix = ".xls";
- break;
- default:
- break;
- }
- _provider.GetPrimaryStream().OpenStream().CopyTo(ms);
- return File(ms.ToArray(), contentType, exportname + System.DateTime.Now.ToString("yyyyMMddHHmmss") + fileShuffix);
复制代码
|