The result of the code is shown below:
using DevExpress.LookAndFeel;
using DevExpress.XtraPivotGrid;
using System.Data.OleDb;
OleDbConnection connection =
new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\DB\\NWIND.MDB");
OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM SalesPerson", connection);
DataSet sourceDataSet = new DataSet();
adapter.Fill(sourceDataSet, "SalesPerson");
pivotGridControl1.DataSource = sourceDataSet.Tables["SalesPerson"];
PivotGridField fieldCountry = new PivotGridField("Country", PivotArea.RowArea);
PivotGridField fieldCustomer = new PivotGridField("Sales Person", PivotArea.RowArea);
fieldCustomer.Caption = "Customer";
PivotGridField fieldYear = new PivotGridField("OrderDate", PivotArea.ColumnArea);
fieldYear.Caption = "Year";
fieldYear.GroupInterval = PivotGroupInterval.DateYear;
PivotGridField fieldCategoryName = new PivotGridField("CategoryName", PivotArea.ColumnArea);
fieldCategoryName.Caption = "Product Category";
PivotGridField fieldProductName = new PivotGridField("ProductName", PivotArea.FilterArea);
fieldProductName.Caption = "Product Name";
PivotGridField fieldExtendedPrice = new PivotGridField("Extended Price", PivotArea.DataArea);
fieldExtendedPrice.CellFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
fieldExtendedPrice.CellFormat.FormatString = "c0";
pivotGridControl1.Fields.AddRange(new PivotGridField[] {fieldCountry, fieldCustomer,
fieldCategoryName, fieldProductName, fieldYear, fieldExtendedPrice});
fieldCountry.AreaIndex = 0;
fieldCustomer.AreaIndex = 1;
fieldCategoryName.AreaIndex = 0;
fieldYear.AreaIndex = 1;
UserLookAndFeel.Default.UseWindowsXPTheme = false;
UserLookAndFeel.Default.Style = LookAndFeelStyle.Skin;
UserLookAndFeel.Default.SkinName = "Money Twins";
populating pivotgrid control with data
BalasHapus