原文:DevExpress XtraReports 入门六 控件以程序方式创建一个 交叉表 报表

本文只是为了帮助初次接触或是需要DevExpress XtraReports报表的人群使用的,为了帮助更多的人不会像我这样浪费时间才写的这篇文章,高手不想的看请路过

本文内容来DevExpress XtraReports帮助文档,如看过类似的请略过。

废话少说 开始正事

在继续本示例之前,要把所有 必需的程序集 添加到项目的 引用 列表中,并且把一个按钮拖放到窗体上。 然后,以下列方式接管此按钮的 Click 事件。

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;
// ...

namespace docXRPivotGrid {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}

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;
}
}
}

DevExpress XtraReports 入门六 控件以程序方式创建一个 交叉表 报表的更多相关文章

  1. CPF 入门教程 - 控件布局(六)

    CPF netcore跨平台桌面UI框架 系列教程 CPF 入门教程(一) CPF 入门教程 - 数据绑定和命令绑定(二) CPF 入门教程 - 样式和动画(三) CPF 入门教程 - 绘图(四) C ...

  2. DevExpress XtraReports 入门五 创建交叉表报表

    原文:DevExpress XtraReports 入门五 创建交叉表报表 本文只是为了帮助初次接触或是需要DevExpress XtraReports报表的人群使用的,为了帮助更多的人不会像我这样浪 ...

  3. DevExpress XtraReports 入门二 创建 data-aware(数据感知) 报表

    原文:DevExpress XtraReports 入门二 创建 data-aware(数据感知) 报表 本文只是为了帮助初次接触或是需要DevExpress XtraReports报表的人群使用的, ...

  4. DevExpress XtraReports 入门三 创建 Master-Detail(主/从) 报表

    原文:DevExpress XtraReports 入门三 创建 Master-Detail(主/从) 报表 本文只是为了帮助初次接触或是需要DevExpress XtraReports报表的人群使用 ...

  5. DevExpress XtraReports 入门四 创建 Web 报表

    原文:DevExpress XtraReports 入门四 创建 Web 报表 本文只是为了帮助初次接触或是需要DevExpress XtraReports报表的人群使用的,为了帮助更多的人不会像我这 ...

  6. DevExpress XtraReports 入门一 创建 Hello World 报表

    原文:DevExpress XtraReports 入门一 创建 Hello World 报表 本文只是为了帮助初次接触或是需要DevExpress XtraReports报表的人群使用的,为了帮助更 ...

  7. 关于 DevExpress.XtraTreeList.TreeList 树形控件 的操作

    作为一个C#程序员,在写程序时一直以来都使用的微软那一套控件,用起来特别爽,可是最近公司的一个项目用到了DevExpress框架,不用不知道,一用吓一跳,不得不承认这个框架确实很强大,效果也很炫,但是 ...

  8. 使用SplashScreenManager控件定制程序加载页面

    需要devexpress版本在12.0及以上才支持 https://www.cnblogs.com/wuhuacong/p/6112461.html 在DevExpress程序中使用SplashScr ...

  9. DevExpress 中 用 LookUpEdit 控件 代替 ComboBoxEdit 控件来绑定 DataTable

    绑定数据及定义列信息 LookUpEdit lue = lookUpEdit1; DataTable dt = new DataTable(); dt.Columns.Add(new DataColu ...

随机推荐

  1. 安卓的sqlite增删改

    基于安卓的sqlite增删改,笔记学习: 1.使用LinearLayout 布局生成,增删改的页面如图 代码布局如下: <LinearLayout xmlns:android="htt ...

  2. WPF技术触屏上的应用系列(六): 视觉冲击、超炫系统主界面、系统入口效果实现

    原文:WPF技术触屏上的应用系列(六): 视觉冲击.超炫系统主界面.系统入口效果实现 去年某客户单位要做个大屏触屏应用,要对档案资源进行展示之用.客户端是Window7操作系统,54寸大屏电脑电视一体 ...

  3. windows下搭建Apache+Mysql+PHP开发环境

    原文:windows下搭建Apache+Mysql+PHP开发环境 要求 必备知识 熟悉基本编程环境搭建. 运行环境 windows 7(64位); Apache2.2;MySQL Server 5. ...

  4. 切割图像(五)主动轮廓模型Snake简要模型

    切割图像(五)主动轮廓模型Snake简要模型 zouxy09@qq.com http://blog.csdn.net/zouxy09 在"图像切割之(一)概述"中咱们简单了解了眼下 ...

  5. 2015广东工业大学ACM学校巡回赛 I 游戏高手 (如压力dp)

    Problem I: 游戏王 Description 小学的时候,Stubird很喜欢玩游戏王.有一天,他发现了一个绝佳的连锁组合,这个连锁组合须要6张卡. 但是他一张都没有,但是他的那些朋友们有.只 ...

  6. Eclipse建筑物SSH(struts-2.2.3 + spring-2.5.6 + hibernate-3.6.8)相框-随着源代码

    一直想自己搭建一个ssh框架,这次因为编写demo的须要,就亲手搭建了一下,并逐步測试!以下进入正题: 创建Struts项目 整合步骤: 1,在Eclipse中创建一个DynamicWeb Proje ...

  7. Android Tween Animation

    View Animation, 它显示在view向上Tween Animation Tween动画.本质上没有变化View对象本身.只要改变它绘制 实施方式有两种.一个xml定义,直接在代码中的定义 ...

  8. 在 Ubuntu 12.04 上安装 GitLab7.x

    安装环境: 操作系统:    Ubuntu 12.4 LTS 英文 数据库:        postgresql webserver: nginx 能够说到7.x的时候,GitLab的文档已经相当完好 ...

  9. Nancy 框架学习

    Nancy 框架 1.是一个轻量级用于构建http相应的web框架: 2.与mvc类似,有自己的路由机制: 3.可以处理 DELETE ,  GET ,  HEAD ,  OPTIONS ,  POS ...

  10. swift 它们的定义TabBarItem

    1.效果图     2.NewsViewController.swift // // NewsViewController.swift // NavigationDemo // // Created ...