我有一個要求,我必須顯示一些數據(來自自定義數據庫),並讓用戶將其導出到Excel文件。在自定義SharePoint WebPart中使用Microsoft.Reporting.WebForms.ReportViewer
我決定使用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);
}
,但現在我不知道查看頁面上的任何數據。我沒有檢查我的數據庫調用,它確實返回一個15行的數據表。任何想法,爲什麼我看不到頁面上的任何內容?
嗯。看起來像這個人:http://stackoverflow.com/questions/1645979/create-asp-net-reportviewer-in-a-child-control-in-asp-net-document-map-button-br有一個類似的問題。 – vinny 2010-04-28 13:40:17