public ActionResult AmbulancePersonSignReport(string startTime, string endTime)
        {
            SS s= new SS();
            List<Ale> list = s.GetInfo(startTime, endTime);            var ReportPath = Server.MapPath("/RDLC/AmbulancePersonSign.rdlc");            var localReport = new Microsoft.Reporting.WebForms.LocalReport { ReportPath = ReportPath };            Microsoft.Reporting.WebForms.ReportParameter pStartTime = new Microsoft.Reporting.WebForms.ReportParameter("StartTime", startTime);
            Microsoft.Reporting.WebForms.ReportParameter pEndTime = new Microsoft.Reporting.WebForms.ReportParameter("EndTime", endTime);
            localReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { pStartTime, pEndTime });            var reportDataSource = new Microsoft.Reporting.WebForms.ReportDataSource("AmbulancePersonSignInfo", list);
            localReport.DataSources.Add(reportDataSource);            string mimeType;
            string encoding;
            string fileNameExtension;
            string reportType = "pdf";            string deviceInfo =
                "<DeviceInfo>" +
                "  <OutputFormat>" + reportType + "</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 = localReport.Render(
                reportType,
                deviceInfo,
                out mimeType,
                out encoding,
                out fileNameExtension,
                out streams,
                out warnings);
 (这段代码总报错:“本地报表处理期间出错”)           
            return File(renderedBytes, mimeType);
        }报表MVC

解决方案 »

  1.   

    帮你调试了一下 异常出现在这里
       Microsoft.Reporting.WebForms.ReportParameter pStartTime = new Microsoft.Reporting.WebForms.ReportParameter("StartTime", startTime);
                Microsoft.Reporting.WebForms.ReportParameter pEndTime = new Microsoft.Reporting.WebForms.ReportParameter("EndTime", endTime);
                localReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { pStartTime, pEndTime });
    这三句有问题
      

  2.   

    An attempt was made to set a report parameter 'StartTime' that is not defined in this report.
      

  3.   

    http://msdn.microsoft.com/zh-cn/library/vstudio/ms251790.aspx
      

  4.   

          string deviceInfo =
                    "<DeviceInfo>" +
                    "  <OutputFormat>" + reportType + "</OutputFormat>" +
                    "  <PageWidth>8.5in</PageWidth>" +
                    "  <PageHeight>11in</PageHeight>" +
                    "  <MarginTop>0.5in</MarginTop>" +
                    "  <MarginLeft>1in</MarginLeft>" +
                    "  <MarginRight>1in</MarginRight>" +
                    "  <MarginBottom>0.5in</MarginBottom>" +

                    "</DeviceInfo>";你把注释掉干嘛?
      

  5.   

          string deviceInfo =
                    "<DeviceInfo>" +
                    "  <OutputFormat>" + reportType + "</OutputFormat>" +
                    "  <PageWidth>8.5in</PageWidth>" +
                    "  <PageHeight>11in</PageHeight>" +
                    "  <MarginTop>0.5in</MarginTop>" +
                    "  <MarginLeft>1in</MarginLeft>" +
                    "  <MarginRight>1in</MarginRight>" +
                    "  <MarginBottom>0.5in</MarginBottom>" +

                    "</DeviceInfo>";你把注释掉干嘛?
    不是那儿的问题,我把“参数属性”那边选择'允许为null',解决了。
    [
      

  6.   

          string deviceInfo =
                    "<DeviceInfo>" +
                    "  <OutputFormat>" + reportType + "</OutputFormat>" +
                    "  <PageWidth>8.5in</PageWidth>" +
                    "  <PageHeight>11in</PageHeight>" +
                    "  <MarginTop>0.5in</MarginTop>" +
                    "  <MarginLeft>1in</MarginLeft>" +
                    "  <MarginRight>1in</MarginRight>" +
                    "  <MarginBottom>0.5in</MarginBottom>" +

                    "</DeviceInfo>";你把注释掉干嘛?
    不是那儿的问题,我把“参数属性”那边选择'允许为null',解决了。
    [
    那就Ok了