你好,你的理解不对
页面显示的报表中,有两个必填的参数,“大件”和“数量”,这个两个参数没有从js中传递过来,是在报表页面提供选择的。选定后,才能显示报表内容
而导出报表的时候,是重新加载了一次报表,然后重新获取数据(这个是根据前段时间的例子程序写的)。这样的话,报表中的那两个参数就没有值
导出excel部分代码
/// <summary>
/// Excel导出
/// </summary>
protected void ExportExcel()
{
// Provide the page report you want to render.
//GrapeCity.ActiveReports.PageReport _reportDef = new GrapeCity.ActiveReports.PageReport(new System.IO.FileInfo(Server.MapPath("/Reports/" + report + ".rdlx")));
GrapeCity.ActiveReports.Document.PageDocument _reportRuntime = new GrapeCity.ActiveReports.Document.PageDocument(_reportDef);
_reportRuntime.LocateDataSource += new GrapeCity.ActiveReports.LocateDataSourceEventHandler(Document_LocateDataSource);
// Create an output directory
System.IO.MemoryStream ms = new System.IO.MemoryStream();
// Provide settings for your rendering output.
GrapeCity.ActiveReports.Export.Excel.Page.ExcelRenderingExtensionSettings
excelSetting = new GrapeCity.ActiveReports.Export.Excel.Page.ExcelRenderingExtensionSettings();
excelSetting.FileFormat = GrapeCity.ActiveReports.Export.Excel.Page.FileFormat.Xls;
excelSetting.MultiSheet = false;
GrapeCity.ActiveReports.Extensibility.Rendering.ISettings setting = excelSetting;
//Set the rendering extension and render the report.
GrapeCity.ActiveReports.Export.Excel.Page.ExcelRenderingExtension
excelRenderingExtension = new
GrapeCity.ActiveReports.Export.Excel.Page.ExcelRenderingExtension();
GrapeCity.ActiveReports.Rendering.IO.MemoryStreamProvider outputProvider = new GrapeCity.ActiveReports.Rendering.IO.MemoryStreamProvider();
_reportRuntime.Render(excelRenderingExtension, outputProvider, excelSetting.GetSettings());
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("content-disposition", "inline;filename=ActiveReport" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".xls");
outputProvider.GetPrimaryStream().OpenStream().CopyTo(ms);
Response.BinaryWrite(ms.ToArray());
//Response.End();
Context.ApplicationInstance.CompleteRequest();
}
|