简体   繁体   English

MVC中的Microsoft RDLC报告

[英]Microsoft rdlc report in MVC

I want to generate report in MVC4 application. 我想在MVC4应用程序中生成报告。 I am trying by Microsoft RDLC report but i don't want to create a data-set. 我正在尝试通过Microsoft RDLC报告,但是我不想创建数据集。 i am creating my own list of data and that list i want to show in the report. 我正在创建自己的数据列表,并且希望在报告中显示该列表。 I am creating list after fetching data from various table. 我从各种表中获取数据后创建列表。 I had gone through various links but all links given me the steps to create report with data-set. 我浏览了各种链接,但是所有链接都为我提供了创建带有数据集的报告的步骤。

I tried to get some from Google , but do not found any reliable solution for same.. Any help will be highly appreciated. 我试图从Google那里获得一些帮助,但没有找到相同的可靠解决方案。任何帮助将不胜感激。

We are using 我们正在使用

public ReportDataSourceCollection DataSources { get; }

from Microsoft.Reporting.WebForms and then add a custom datasource to our report engine with 然后从Microsoft.Reporting.WebForms中添加一个自定义数据源到我们的报表引擎

myReportEngine.DataSources.Add(new ReportDataSource("MyData", data));

where data can be DataTable, IDataSource or an IEnumerable as you need it. 其中的数据可以是DataTable,IDataSource或所需的IEnumerable。

In the report definition (rdlc) we use the following dummy data set that maps to our data 在报告定义(rdlc)中,我们使用以下虚拟数据集映射到我们的数据

<DataSources>
  <DataSource Name="MyDataSource">
    <ConnectionProperties>
      <DataProvider>SQL</DataProvider>
      <ConnectString>data source=localhost;initial catalog=MyDataCollection</ConnectString>
      <IntegratedSecurity>true</IntegratedSecurity>
    </ConnectionProperties>
  </DataSource>
</DataSources>
<DataSets>
  <DataSet Name="MyData">
    <Fields>
      <Field Name="MyField1">
        <DataField>MyField1</DataField>
    </Field>
    ...
   </Fields>
  </DataSet>
</DataSets>

Comment: MyDataCollection and MyDataSource must not be set in code. 注释:不能在代码中设置MyDataCollection和MyDataSource。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM