How to: Create a Cross-Tab Report (Runtime Sample)

简介: C#VB using System; using System.Data; using System.Data.OleDb; using System.Windows.Forms; using DevExpress.
C#

VB

using System; using System.Data; using System.Data.OleDb; using System.Windows.Forms; using DevExpress.XtraPivotGrid; using DevExpress.XtraReports.UI; using DevExpress.XtraReports.UI.PivotGrid; // ...  private void button1_Click(object sender, EventArgs e) {     // Create a cross-tab report.     XtraReport report = CreateReport();      // Show its Print Preview.     report.ShowPreview(); }  private XtraReport CreateReport() {     // Create a blank report.     XtraReport rep = new XtraReport();      // Create a detail band and add it to the report.     DetailBand detail = new DetailBand();     rep.Bands.Add(detail);      // Create a pivot grid and add it to the Detail band.     XRPivotGrid pivotGrid = new XRPivotGrid();     detail.Controls.Add(pivotGrid);      // Create a data connection.     OleDbConnection connection = new         OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\\..\\nwind.mdb");      // Create a data adapter.     OleDbDataAdapter adapter = new         OleDbDataAdapter("SELECT CategoryName, ProductName, Country, [Sales Person],          Quantity, [Extended Price] FROM SalesPerson", connection);      // Creata a dataset and fill it.     DataSet dataSet1 = new DataSet();     adapter.Fill(dataSet1, "SalesPerson");       // Bind the pivot grid to data.     pivotGrid.DataSource = dataSet1;     pivotGrid.DataMember = "SalesPerson";      // Generate pivot grid's fields.     XRPivotGridField fieldCategoryName =          new XRPivotGridField("CategoryName", PivotArea.RowArea);     XRPivotGridField fieldProductName =          new XRPivotGridField("ProductName", PivotArea.RowArea);     XRPivotGridField fieldCountry =          new XRPivotGridField("Country", PivotArea.ColumnArea);     XRPivotGridField fieldSalesPerson =          new XRPivotGridField("Sales Person", PivotArea.ColumnArea);     XRPivotGridField fieldQuantity =          new XRPivotGridField("Quantity", PivotArea.DataArea);     XRPivotGridField fieldExtendedPrice =          new XRPivotGridField("Extended Price", PivotArea.DataArea);      // Add these fields to the pivot grid.     pivotGrid.Fields.AddRange(new PivotGridField[] {fieldCategoryName,           fieldProductName, fieldCountry, fieldSalesPerson, fieldQuantity,           fieldExtendedPrice});      return rep; }  
目录
相关文章
|
5月前
SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘thinkphp.test‘ don‘t exsit
SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘thinkphp.test‘ don‘t exsit
88 0
|
3月前
|
机器学习/深度学习 人工智能
【CatBoost报错解决】CatBoostError: Bad value for num feature[non default doc idx=0,feature idx=19]=
【CatBoost报错解决】CatBoostError: Bad value for num feature[non default doc idx=0,feature idx=19]=
MGA (Managed Global Area) Reference Note (Doc ID 2638904.1)
MGA (Managed Global Area) Reference Note (Doc ID 2638904.1)
220 0
custom field further usage - add into UI and report
custom field further usage - add into UI and report
113 0
custom field further usage - add into UI and report
jMeter CSV Data set config 的 sharing mode 和 Thread group loop 配合使用
jMeter CSV Data set config 的 sharing mode 和 Thread group loop 配合使用
133 0
jMeter CSV Data set config 的 sharing mode 和 Thread group loop 配合使用
How to add extension field to report
How to add extension field to report
106 0
Cluster table import - BSP UI component source code is actually stored in cluster table
Cluster table import - BSP UI component source code is actually stored in cluster table
Cluster table import - BSP UI component source code is actually stored in cluster table
UDO report generate DDIC table
UDO report generate DDIC table
118 0
UDO report generate DDIC table
How to create unit test for product determination function module
How to create unit test for product determination function module
116 0
How to create unit test for product determination function module
成功解决model_selection\_search.py:761: DeprecationWarning: The grid_scores_ attribute was deprecated in
成功解决model_selection\_search.py:761: DeprecationWarning: The grid_scores_ attribute was deprecated in