原創|其它|編輯:郝浩|2012-10-17 17:29:20.000|閱讀 284 次
概述:數據查看一直是我們的常規應用,那么DevExpress是如何在運行時查看Adventure Works多維數據集數據的呢?下面,我們就給出一個具體代碼事例供大家參考.
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
數據查看一直是我們的常規應用,那么DevExpress是如何在運行時查看Adventure Works多維數據集數據的呢?下面,我們就給出一個具體代碼事例供大家參考:
C#
using DevExpress.XtraPivotGrid;
// Create a PivotGridControl.
PivotGridControl pivotControl = new PivotGridControl();
pivotControl.Dock = DockStyle.Fill;
this.Controls.Add(pivotControl);
// Specify the connection string
pivotControl.OLAPConnectionString = "Provider=msolap;Data Source=localhost;Initial Catalog=Adventure Works DW;Cube Name=Adventure Works;";
// Create fields.
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";
// Add fields to the PivotGridControl
pivotControl.Fields.AddRange(new PivotGridField[] { fieldMeasuresInternetSalesAmount, fieldCustomerCountryCountry,
fieldDateFiscalYearFiscalYear });
VB
Imports DevExpress.XtraPivotGrid
' Create a PivotGridControl.
Dim pivotControl As PivotGridControl = New PivotGridControl()
pivotControl.Dock = DockStyle.Fill
Me.Controls.Add(pivotControl)
' Specify the connection string
pivotControl.OLAPConnectionString = "Provider=msolap;Data Source=localhost;Initial Catalog=Adventure Works DW;Cube Name=Adventure Works;"
' Create fields.
Dim fieldMeasuresInternetSalesAmount As PivotGridField = New PivotGridField("[Measures].[Internet Sales Amount]", PivotArea.DataArea)
fieldMeasuresInternetSalesAmount.Caption = "Internet Sales Amount"
Dim fieldCustomerCountryCountry As PivotGridField = New PivotGridField("[Customer].[Country].[Country]", PivotArea.RowArea)
fieldCustomerCountryCountry.Caption = "Country"
Dim fieldDateFiscalYearFiscalYear As PivotGridField = New PivotGridField("[Date].[Fiscal Year].[Fiscal Year]", PivotArea.ColumnArea)
fieldDateFiscalYearFiscalYear.Caption = "Fiscal Year"
' Add fields to the PivotGridControl
pivotControl.Fields.AddRange(New PivotGridField() {fieldMeasuresInternetSalesAmount, fieldCustomerCountryCountry, _
fieldDateFiscalYearFiscalYear})
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@ke049m.cn
文章轉載自:慧都控件網