我有一个使用 MVC 中的报告创建的折线图。但无法使用视图显示它。有人可以帮助我如何在 MVC 中显示 rdlc 图表吗?
问问题
992 次
1 回答
0
我尝试了一种不同的方法……对我来说,它奏效了。您需要做的第一件事是:
Add -> Microsoft.ReportingServices.ReportViewerControl.WebForms by Microsoft
***make sure that all the packages are in the 16 version.***
有了这个包,你只需要添加报表,添加一个dataModel,然后将它绑定到报表数据集,你将不再需要一个viewForm。
在这种方法中,您将使用控制器:
.add data (example):
EmpresaEntities emp_entities = new EmpresaEntities();
ReportDataSource emp_datasource = new ReportDataSource("Empresa", (from empresa in emp_entities.FourAll_Empresa select empresa));
viewer.LocalReport.DataSources.Clear();
viewer.LocalReport.DataSources.Add(emp_datasource);
. merge data(exemple):
MergeModels models = new MergeModels();
models._Empresas = (from FourAll_Empresa in emp_entities.FourAll_Empresa select FourAll_Empresa).ToList();
models._Entidades = (from FourAll_Entidade in ent_entidade.FourAll_Entidade select FourAll_Entidade).ToList();
.define the size of a window(example):
viewer.SizeToReportContent = false;
const int ConstantePercentagem = 100;
viewer.Width = Unit.Percentage(ConstantePercentagem);
viewer.Height = Unit.Pixel(800);
viewer.ZoomMode = ZoomMode.FullPage;
.return viewer(exemple):
ViewBag.ReportViewer = viewer;
return View( models);
这将使您的报告准备好数据:)
在 Index.cshtml 中:
@using ReportViewerForMvc;
@using System.Web.UI.WebControls;
@using System.Web.Mvc;
@{
ViewBag.Title = "Index";
}
@Html.ReportViewer(ViewBag.ReportViewer as Microsoft.Reporting.WebForms.ReportViewer, new { scrolling = "yes", Width = "1200px", Height = "800px" })
于 2018-08-13T16:00:19.903 回答