同样的程序发布在两台服务器上,一台正常,一台导出报如图错误。是缺少什么配置或者组件吗?两台服务器的系统配置一模一样。
这是导出的代码
- protected void btnExcel_Click(object sender, EventArgs e)
- {
- GenerateReport();
- System.IO.MemoryStream ms = new System.IO.MemoryStream();
- // 导出Excel文件设置
- GrapeCity.ActiveReports.Export.Excel.Page.ExcelRenderingExtensionSettings excelSetting = new GrapeCity.ActiveReports.Export.Excel.Page.ExcelRenderingExtensionSettings();
- excelSetting.FileFormat = GrapeCity.ActiveReports.Export.Excel.Page.FileFormat.Xls;
- excelSetting.OpenXmlStandard = GrapeCity.ActiveReports.Export.Excel.Page.OpenXmlStandard.Transitional;
- excelSetting.Pagination = true;
- excelSetting.MultiSheet = false;
- GrapeCity.ActiveReports.Extensibility.Rendering.ISettings setting = excelSetting;
- //设置渲染方式
- 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();
- report.Document.Render(excelRenderingExtension, outputProvider, excelSetting.GetSettings());
- Response.ContentType = "application/vnd.ms-excel";
- Response.AddHeader("content-disposition", "inline;filename=MyExport.xls");
- outputProvider.GetPrimaryStream().OpenStream().CopyTo(ms);
- Response.BinaryWrite(ms.ToArray());
- Response.End();
- }
复制代码
|