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
{
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
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 });
这三句有问题
"<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>";你把注释掉干嘛?
"<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',解决了。
[
"<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了