【发布时间】: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 行的数据表。任何想法为什么我在页面上看不到任何内容?
【问题讨论】:
-
嗯。貌似这个人:stackoverflow.com/questions/1645979/…也有类似的问题。
标签: sharepoint-2007 web-parts reportviewer