请查看以下代码,添加了 _reportRuntime.LocateDataSource += new GrapeCity.ActiveReports.LocateDataSourceEventHandler(Document_LocateDataSource);
- protected void btnExcel_Click(object sender, EventArgs e)
- {
- string path = Server.MapPath("rptSalesByCategory.rdlx");
- GrapeCity.ActiveReports.PageReport rptPreview = new GrapeCity.ActiveReports.PageReport(new System.IO.FileInfo(path));
- WebViewer1.LocateDataSource += new GrapeCity.ActiveReports.LocateDataSourceEventHandler(Document_LocateDataSource);
-
- WebViewer1.Report = rptPreview;
- GrapeCity.ActiveReports.Document.PageDocument _reportRuntime = new GrapeCity.ActiveReports.Document.PageDocument(rptPreview);
- _reportRuntime.LocateDataSource += new GrapeCity.ActiveReports.LocateDataSourceEventHandler(Document_LocateDataSource);
- GrapeCity.ActiveReports.Export.Excel.Section.XlsExport XlsExport1 = new GrapeCity.ActiveReports.Export.Excel.Section.XlsExport();
- System.IO.MemoryStream ms = new System.IO.MemoryStream();
- XlsExport1.FileFormat = GrapeCity.ActiveReports.Export.Excel.Section.FileFormat.Xlsx;
- XlsExport1.Export(_reportRuntime, ms);
- Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
- Response.AddHeader("content-disposition", Server.UrlPathEncode("attachment;filename=客户订单.xlsx"));
- Response.BinaryWrite(ms.ToArray());
- Response.End();
- }
复制代码 |