Sharepoint 2007 在自定义SharePoint Web部件中使用Microsoft.Reporting.WebForms.ReportViewer
我需要显示一些数据(来自自定义数据库),并让用户将其导出到excel文件 我决定使用Microsoft.Reporting.WebForms.ReportViewer中的ReportViewer控件。我向项目引用中添加了所需的程序集,并添加了以下代码对其进行测试Sharepoint 2007 在自定义SharePoint Web部件中使用Microsoft.Reporting.WebForms.ReportViewer,sharepoint-2007,web-parts,reportviewer,Sharepoint 2007,Web Parts,Reportviewer,我需要显示一些数据(来自自定义数据库),并让用户将其导出到excel文件 我决定使用Microsoft.Reporting.WebForms.ReportViewer中的ReportViewer控件。我向项目引用中添加了所需的程序集,并添加了以下代码对其进行测试 protected override void CreateChildControls() { base.CreateChildControls(); objRV = n
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"...
但现在我在页面上看不到任何数据。我确实检查了我的db调用,它确实返回了一个包含15行的数据表。你知道为什么我在页面上看不到任何内容吗?你是否在SharePoint web应用程序下运行报表服务器?将
添加到报告网站的web.config中,或从sharepoint web.config中删除
,应该会将其清除。不确定这会对ootb reportviewer web部件产生怎样的影响,但是(测试,测试,测试).谢谢,我尝试了你所说的,并且成功了。但是,我没有使用Web部件,我只是简单地使用Microsoft.Reporting.WebForms中的类。我还没有探究行动的结果。看起来这家伙也有类似的问题。
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);
}