Asp.net mvc 如何在MVC中显示RDLC图表而不使用ASPX

Asp.net mvc 如何在MVC中显示RDLC图表而不使用ASPX,asp.net-mvc,reporting-services,rdlc,ssrs-2012,dynamic-rdlc-generation,Asp.net Mvc,Reporting Services,Rdlc,Ssrs 2012,Dynamic Rdlc Generation,我在MVC中使用报告创建了一个折线图。但无法使用视图显示它。有人能帮助我如何在MVC中显示rdlc图表吗?我尝试了一种不同的方法。。。对我来说,它奏效了。 您需要做的第一件事是: Add -> Microsoft.ReportingServices.ReportViewerControl.WebForms by Microsoft ***make sure that all the packages are in the 16 version.*** 使用此软件包,您只需添加报表、添

我在MVC中使用报告创建了一个折线图。但无法使用视图显示它。有人能帮助我如何在MVC中显示rdlc图表吗?

我尝试了一种不同的方法。。。对我来说,它奏效了。 您需要做的第一件事是:

 Add -> Microsoft.ReportingServices.ReportViewerControl.WebForms by Microsoft

***make sure that all the packages are in the 16 version.***
使用此软件包,您只需添加报表、添加数据模型,然后将其绑定到报表数据集,就不再需要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" })

如果没有WebForms库,您就无法实现这一点(因此您应该将它们添加到project中)。但是如果你不需要交互,你可以将它呈现为一个文件(例如exel)并下载。谢谢teo van kot..@teovankot:我在这里找到了一种方法,但它对我不起作用。它说system.web.mvc.htmlhelper dynamic不包含“报表查看器”的定义……我尝试添加名称空间,但如果您检查它使用的依赖项,它仍然不起作用,因此它是webforms组件。如果您需要有关安装的帮助,请使用所有details@teovankot:我已经在我的项目中安装了此功能,但使用报表查看器时仍然存在问题。