【问题标题】:How to display RDLC charts in MVC without using ASPX如何在不使用 ASPX 的情况下在 MVC 中显示 RDLC 图表
【发布时间】:2016-08-01 07:07:08
【问题描述】:

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

【问题讨论】:

  • 如果没有 WebForms 库,您将无法做到这一点(所以无论如何您都应该将它们添加到项目中)。但如果您不需要交互,您可以将其渲染为文件(例如 exel)并下载。
  • 谢谢 teo van kot ..
  • @teovankot:我在这里找到了一种方法reportviewerformvc.codeplex.com/…,但它对我不起作用。它说 system.web.mvc.htmlhelper 动态不包含“报告查看器”的定义..我尝试添加命名空间,但仍然无法正常工作
  • 如果您检查依赖关系,它使用MicosoftReportViewerWebForms_v11,所以它是网络表单组件。如果您在安装方面需要帮助 - 请创建另一个包含所有详细信息的问题
  • @teovankot:我已经在我的项目中安装了这个,但是使用报告查看器仍然存在问题。

标签: asp.net-mvc reporting-services rdlc ssrs-2012 dynamic-rdlc-generation


【解决方案1】:

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

 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" })

【讨论】:

    猜你喜欢
    • 2010-09-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-09-24
    • 2011-12-17
    相关资源
    最近更新 更多