
cube
-
个人空间
- 组别:版主
- 性别:
- 来自:
- 积分:17
- 帖子:17
- 注册:
2008-04-14
|
使用XtraPivotGrid 展示数据透视表
使用这片文章中的代码首先要安装Developer Express .NET v7.1 下载地址:http://www.devexpress.com/Downloads/ 网上也有很多破解版本下载,用以提供给那些学习的朋友使用。XtraPivotGrid这个控件是类似于微软OWC11中的PivotTable透视表控件,它非常方便的支持展示OLAP服务器的多维数据集。安装好Developer Express .NET v7.1以后,就会发现我们的vs2005的toolbox上面多了很多控件。

然后我们把PivotGridControl拖动到我们的form窗体上去。然后编写form的load事件,绑定控件的数据源,代码如下:this.pivotGridControl1.OLAPConnectionString = "Provider=msolap;Data Source=localhost;Initial Catalog=Adventure Works DW Standard Edition;Cube Name=Adventure Works;"; PivotGridField fieldMeasuresInternetSalesAmount = new PivotGridField("[Measures].[Internet Sales Amount]", PivotArea.DataArea); fieldMeasuresInternetSalesAmount.Caption = "Internet Sales Amount"; PivotGridField fieldCustomerCountryCountry = new PivotGridField("[Customer].[Country].[Country]", PivotArea.RowArea); fieldCustomerCountryCountry.Caption = "Country"; PivotGridField fieldDateFiscalYearFiscalYear = new PivotGridField("[Date].[Fiscal Year].[Fiscal Year]", PivotArea.ColumnArea); fieldDateFiscalYearFiscalYear.Caption = "Fiscal Year"; this.pivotGridControl1.Fields.AddRange(new PivotGridField[] { fieldMeasuresInternetSalesAmount, fieldCustomerCountryCountry, fieldDateFiscalYearFiscalYear }); 运行结果:
 好了,打完收工,类似于OWC11中的PivotTable的功能完成了。有的朋友要问了,为什么直接用OWC呢?因为我不会用,呵呵,从来没有用OWC做过东西,相反,xtra这套控件我是相当熟悉,因为我们公司就用这套软件来开发ERP的。原文出处:http://www.cnblogs.com/lijun4017/
|