【问题标题】:Using Microsoft.Reporting.WebForms.ReportViewer in a custom SharePoint WebPart在自定义 SharePoint WebPart 中使用 Microsoft.Reporting.WebForms.ReportViewer
【发布时间】:2011-02-12 22:32:54
【问题描述】:

我有一个要求,我必须显示一些数据(来自自定义数据库)并让用户将其导出到 Excel 文件。

我决定使用 Microsoft.Reporting.WebForms.ReportViewer 中的 ReportViewer 控件。我将所需的程序集添加到项目引用中,并添加以下代码进行测试

protected override void CreateChildControls()
        {
            base.CreateChildControls();

            objRV = new Microsoft.Reporting.WebForms.ReportViewer();
            objRV.ID = "objRV";
            this.Controls.Add(objRV);
        }

第一个错误要求我在 web.config 中添加这一行

我做了,下一个错误说

The type 'Microsoft.SharePoint.Portal.Analytics.UI.ReportViewerMessages, Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' does not implement IReportViewerMessages

是否可以在我的自定义 Web 部件中使用 ReportViewer?我宁愿不绑定中继器并编写自己的导出到 excel 代码。我想使用微软已经构建的东西?关于我可以重复使用什么的任何想法?

编辑

我评论了下面一行

<add key="ReportViewerMessages"...

现在我的代码在我添加数据源后看起来像这样

protected override void CreateChildControls()
        {
            base.CreateChildControls();

            objRV = new Microsoft.Reporting.WebForms.ReportViewer();
            objRV.ID = "objRV";
            objRV.Visible = true;

            Microsoft.Reporting.WebForms.ReportDataSource datasource = new Microsoft.Reporting.WebForms.ReportDataSource("test", GroupM.Common.DB.GetAllClientCodes());
            objRV.LocalReport.DataSources.Clear();
            objRV.LocalReport.DataSources.Add(datasource);

            objRV.LocalReport.Refresh();

            this.Controls.Add(objRV);
        }

但现在我在页面上看不到任何数据。我确实检查了我的 db 调用,它确实返回了一个包含 15 行的数据表。任何想法为什么我在页面上看不到任何内容?

【问题讨论】:

标签: sharepoint-2007 web-parts reportviewer


【解决方案1】:

您是否在 SharePoint Web 应用程序下运行报表服务器?将&lt;remove key="ReportViewerMessages" /&gt; 添加到您的报告站点的web.config,或从您的sharepoint web.config 中删除&lt;add key="ReportViewerMessages"... /&gt; 应该可以清除它。不确定这会如何影响 ootb reportviewer Web 部件,但(测试、测试、测试)...

【讨论】:

  • 谢谢,你说的我试过了,它奏效了。但是,我没有使用 WebPart,我使用 Microsoft.Reporting.WebForms 中的类很简单。我还没有探索行动的结果。
猜你喜欢
  • 2011-07-10
  • 2011-08-23
  • 2011-08-24
  • 2011-06-03
  • 2011-06-13
  • 2021-01-16
  • 1970-01-01
  • 2010-10-20
  • 1970-01-01
相关资源
最近更新 更多