【发布时间】:2011-02-24 12:08:44
【问题描述】:
我使用 SQL Server 报告服务生成报告。我已经生成了一份报告并将 .rdl 报告文件放在“E”驱动器中。现在,当我将 .rdl 报告文件呈现为 pdf 格式时,我收到异常:-“本地报告处理期间发生错误。”
堆栈跟踪如下:-
在 Microsoft.Reporting.WebForms.LocalReport.InternalRender(字符串格式,布尔值 allowInternalRenderers,字符串 deviceInfo,CreateAndRegisterStream createStreamCallback,Warning[]& 警告)
在 Microsoft.Reporting.WebForms.LocalReport.InternalRender(字符串格式,布尔值在 Microsoft.Reporting.WebForms.LocalReport.Render(字符串格式,字符串设备信息,字符串和 mimeType,字符串& encoding, String& fileNameExtension, String[]& streams, Warning[]& warnings)
在 SaltlakeSoft.APEX2.Controllers.TestPageController.RenderReport() 在 E:\Documents and Settings\Administrator\Desktop\afetbuild15thmayapex2\apex2\Controllers\ TestPageController.cs:line 1626
在 lambda_method(ExecutionScope , ControllerBase , Object[] )
在 System.Web.Mvc.ActionMethodDispatcher.c_DisplayClass1.b_0(ControllerBase 控制器, Object[] 参数)
在 System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase 控制器,Object[] 参数)
在 System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext 控制器上下文,IDictionary2 参数)
在 System.Web.Mvc.ControllerActionInvoker .InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 参数)
在 System.Web.Mvc.ControllerActionInvoker.c_DisplayClassa.b_7()
在 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func `1 续)
我正在使用以下代码:-
LocalReport report = new LocalReport();
report.ReportPath = @"E:\Report1.rdl";
List<Employee> employeeCollection = empRepository.FindAll().ToList();
ReportDataSource reportDataSource = new ReportDataSource("dataSource1",employeeCollection);
report.DataSources.Clear();
report.DataSources.Add(reportDataSource);
report.Refresh();
string reportType = "PDF";
string mimeType;
string encoding;
string fileNameExtension;
string deviceInfo ="<DeviceInfo>" +"<OutputFormat>PDF</OutputFormat>" +
"<PageWidth>8.5in</PageWidth>" + "<PageHeight>11in</PageHeight>" +
"<MarginTop>0.5in</MarginTop>" +"<MarginLeft>1in</MarginLeft>" +
"<MarginRight>1in</MarginRight>" +"<MarginBottom>0.5in</MarginBottom>" +
"</DeviceInfo>";
Warning[] warnings;
string[] streams;
byte[] renderedBytes;
renderedBytes = report.Render(reportType,deviceInfo,out mimeType,out encoding, out fileNameExtension, out streams, out warnings);
Response.Clear();
Response.ContentType = mimeType;
Response.AddHeader("content-disposition", "attachment; filename=foo." + fileNameExtension);
Response.BinaryWrite(renderedBytes);
Response.End();
【问题讨论】:
标签: sql-server reporting-services