MVC使用RDLC输出文件,为什么提示“本地报表处理期间出错”?

嫣如舜华 2013-07-30 05:31:51
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);
}
...全文
507 14 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
newtee 2013-08-01
  • 打赏
  • 举报
回复
引用 10 楼 xinguotiantian 的回复:
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>";你把注释掉干嘛?
嫣如舜华 2013-08-01
  • 打赏
  • 举报
回复
还是要感谢你啊!嘿嘿
newtee 2013-08-01
  • 打赏
  • 举报
回复
引用 12 楼 xinguotiantian 的回复:
[quote=引用 11 楼 zhuankeshumo 的回复:] [quote=引用 10 楼 xinguotiantian 的回复:]
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>";你把注释掉干嘛?[/quote] 不是那儿的问题,我把“参数属性”那边选择'允许为null',解决了。 [ [/quote]那就Ok了
嫣如舜华 2013-08-01
  • 打赏
  • 举报
回复
引用 11 楼 zhuankeshumo 的回复:
[quote=引用 10 楼 xinguotiantian 的回复:]

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>";你把注释掉干嘛?[/quote]


不是那儿的问题,我把“参数属性”那边选择'允许为null',解决了。
[


嫣如舜华 2013-07-31
  • 打赏
  • 举报
回复
嫣如舜华 2013-07-31
  • 打赏
  • 举报
回复
第一次成功打开了,现在怎么又报错:

嫣如舜华 2013-07-31
  • 打赏
  • 举报
回复
谢谢6楼,我改了下报表参数的数据类型,解决了!万分感谢~
newtee 2013-07-30
  • 打赏
  • 举报
回复
弄了一个小时
newtee 2013-07-30
  • 打赏
  • 举报
回复
__岑__ 2013-07-30
  • 打赏
  • 举报
回复
newtee 2013-07-30
  • 打赏
  • 举报
回复
An attempt was made to set a report parameter 'StartTime' that is not defined in this report.
newtee 2013-07-30
  • 打赏
  • 举报
回复
帮你调试了一下 异常出现在这里


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 });
这三句有问题
EnForGrass 2013-07-30
  • 打赏
  • 举报
回复
应该还有更详细的错误

111,098

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧