没有iframe的RDLC报告MVC 5 [英] RDLC report MVC 5 without iframe
本文介绍了没有iframe的RDLC报告MVC 5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有更好的方法可以将rdlc报告集成到mvc 5 asp.net上. 每个人都在使用iframe进行展示.但我不喜欢这种解决方案.
Is there any better way to integrate rdlc report on mvc 5 asp.net. everyone is showing using iframe. but i don't like that solution.
有什么优雅的解决方案吗?
Is there any elegant solution ??
推荐答案
如何在单独的选项卡中呈现rdlc报告 ?!
How about rendering your rdlc report in a separate tab ?!
例如,
在您的控制器中:
public ActionResult Report()
{
LocalReport localReport = new LocalReport();
localReport.ReportPath = Server.MapPath("~/Reports/Report1.rdlc");
// you may comment dbContext if the report is static or needs no DB-connection
using (dbContext db = new dbContext())
{
ReportDataSource ds1 = new ReportDataSource("DataSet_Header", db.table_X.ToList());
ReportDataSource ds2 = new ReportDataSource("DataSet_Detail", db.StoreedProcedure_X(5).ToList());
// ...
localReport.DataSources.Add(ds1);
localReport.DataSources.Add(ds2);
string mimeType;
string encoding;
string fileNameExtension;
Warning[] warnings;
string[] streams;
string reportType = "PDF";
string deviceInfo = "<DeviceInfo>" +
"<OutputFormat>PDF</OutputFormat>"+
"<PageWidth>11.69in</PageWidth>"+
"<PageHeight>8.27in</PageHeight>"+
"</DeviceInfo>";
byte[] renderBytes;
// add report parameters here, if any
Microsoft.Reporting.WebForms.ReportParameter[] para = new ReportParameter[] {
new ReportParameter("sample", Sample.ToString())
// , add more parameters if anymore exists ...
};
localReport.SetParameters(para);
renderBytes = localReport.Render(
reportType,
deviceInfo,
out mimeType,
out encoding,
out fileNameExtension,
out streams,
out warnings
);
return File(renderBytes, "application/pdf");
} // end using
}
在您看来:
您可以为上述操作方法创建<a>
标签或@Html.ActionLink
:
You can create <a>
tag or @Html.ActionLink
to the above action method:
<a href="@Url.Action("Report", "controllerName")">PRINT</a>
希望这会有所帮助:)
这篇关于没有iframe的RDLC报告MVC 5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文