DevExpress XtraReports 入门六 控件以程序方式创建一个 交叉表 报表
原文: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 入门六 控件以程序方式创建一个 交叉表 报表的更多相关文章
- CPF 入门教程 - 控件布局(六)
CPF netcore跨平台桌面UI框架 系列教程 CPF 入门教程(一) CPF 入门教程 - 数据绑定和命令绑定(二) CPF 入门教程 - 样式和动画(三) CPF 入门教程 - 绘图(四) C ...
- DevExpress XtraReports 入门五 创建交叉表报表
原文:DevExpress XtraReports 入门五 创建交叉表报表 本文只是为了帮助初次接触或是需要DevExpress XtraReports报表的人群使用的,为了帮助更多的人不会像我这样浪 ...
- DevExpress XtraReports 入门二 创建 data-aware(数据感知) 报表
原文:DevExpress XtraReports 入门二 创建 data-aware(数据感知) 报表 本文只是为了帮助初次接触或是需要DevExpress XtraReports报表的人群使用的, ...
- DevExpress XtraReports 入门三 创建 Master-Detail(主/从) 报表
原文:DevExpress XtraReports 入门三 创建 Master-Detail(主/从) 报表 本文只是为了帮助初次接触或是需要DevExpress XtraReports报表的人群使用 ...
- DevExpress XtraReports 入门四 创建 Web 报表
原文:DevExpress XtraReports 入门四 创建 Web 报表 本文只是为了帮助初次接触或是需要DevExpress XtraReports报表的人群使用的,为了帮助更多的人不会像我这 ...
- DevExpress XtraReports 入门一 创建 Hello World 报表
原文:DevExpress XtraReports 入门一 创建 Hello World 报表 本文只是为了帮助初次接触或是需要DevExpress XtraReports报表的人群使用的,为了帮助更 ...
- 关于 DevExpress.XtraTreeList.TreeList 树形控件 的操作
作为一个C#程序员,在写程序时一直以来都使用的微软那一套控件,用起来特别爽,可是最近公司的一个项目用到了DevExpress框架,不用不知道,一用吓一跳,不得不承认这个框架确实很强大,效果也很炫,但是 ...
- 使用SplashScreenManager控件定制程序加载页面
需要devexpress版本在12.0及以上才支持 https://www.cnblogs.com/wuhuacong/p/6112461.html 在DevExpress程序中使用SplashScr ...
- DevExpress 中 用 LookUpEdit 控件 代替 ComboBoxEdit 控件来绑定 DataTable
绑定数据及定义列信息 LookUpEdit lue = lookUpEdit1; DataTable dt = new DataTable(); dt.Columns.Add(new DataColu ...
随机推荐
- 区间第K大
protected static int partitions(List<KDNode> data,int left,int right,int k,int pos){ int l = l ...
- WPF 引用DLL纯图像资源包类库中的图片
原文:WPF 引用DLL纯图像资源包类库中的图片 1.建立WPF应用程序 过程略. 2.创建类库项目(图片资源包) 创建图片资源类库项目MyImages,删除 ...
- CentOS 安装apache 及所需的 apr,apr-util,pcre
安装apache前确定已安装 apr,apr-util,pcre 一.安装apr [root@xt test]# tar -zxf apr-1.4.5.tar.gz [root@xt test]# c ...
- Acdreamoj1115(数学思维称号)
意甲冠军:1,3是完美的数,假定a,b是完美的数,然后,2+a*b+2*a+2*b,结论认为,n无论是完美的数字. 解法:開始仅仅看出来2+a*b+2*a+2*b=(a+2)*(b+2)-2,没推出很 ...
- HttpLuaModule——翻译(Nginx API for Lua) (转)
现在我已经将翻译的内容放到:http://wiki.nginx.org/HttpLuaModuleZh Nginx API for Lua Introduction 各种各样的*_by_lua和*_b ...
- freemarker错误七
1.错误叙述性说明 五月 30, 2014 11:33:57 下午 freemarker.log.JDK14LoggerFactory$JDK14Logger error 严重: Template p ...
- [LeetCode202]Happy Number判断一个数是不是happy number
题目: Write an algorithm to determine if a number is "happy". A happy number is a number def ...
- yum 安装时错误 Errno 14 Couldn't resolve host 解决办法(转)
在安装mlocate的时候发现一直报错,错误内容大致如下 Downloading Packages:http://mirrors.163.com/centos/6.5/os/i386/Packages ...
- 单链表---java实现
单链表优点:1.不需要预先给出元素个数. 2.单链表插入删除时不需要移动数据元素. 单链表缺点:1.每个节点有指针,空间利用率低. 2.单链表不支持随机读取数据. Node.java package ...
- Nuget的使用
前言 最近看到园子上有关于NuGet (读音:new get)的使用,所以心血来潮也跟着学习做了一下,觉得很流b哦.于是也就记一下自己的学习心得(并非一味的重复轮子,只是觉得他人做的写的就是对的,自己 ...