-
新建工程
-
在工程中添加ActiveReports报表文件
-
添加报表数据源
-
浏览报表
-
发布 ActiveReports 应用
本片文章将阐述首次在 WPF 平台下使用 ActiveReports 报表控件的方法。
主要内容包括:
下面我们来分布讲解:
一.按照如图所示步骤创建 WPF 工程:
二.在工程中添加ActiveReports报表文件
1、从 Visual Studio项目菜单 (或在 Web 项目中的网站菜单),选择添加新项。
2、选择您想要添加的报告的类型,这里我们选择RDL报表做演示:
3.添加报表数据源
打开视图里面的报表资源管理器,添加数据源
填写数据链接信息
4.添加数据集
打开视图里面的报表资源管理器,在数据源下添加数据集
增加查询语句
5.添加Table到报表中
Table可以直接选取需要的字段
三.浏览报表
1.在 “MainWindow” 窗体中添加 ActiveReports Viewer 报表浏览器:
2.后台添加代码映射报表到报表浏览器,代码如下:
string file_name = @"..\..\RdlReport1.rdlx";GrapeCity.ActiveReports.PageReport pageReport = new GrapeCity.ActiveReports.PageReport(new System.IO.FileInfo(file_name));GrapeCity.ActiveReports.Document.PageDocument pageDocument = new GrapeCity.ActiveReports.Document.PageDocument(pageReport);
viewer1.LoadDocument(pageDocument);四.运行项目查看效果:
五.发布 ActiveReports 应用
设置 ActiveReports 报表控件 DLL 复制本地属性为 True:
重新编译后拷贝Release文件到客户端即可使用。
六.示例下载:
VS2010 + .NET 4.0 + AR