(转)[原创] RDLC 报表系列(五) RDLC报表分组
2011-05-04 23:29
323 查看
原文地址:/article/5681406.html
本文只代表作者在一定阶段的认识与理解。
一、写作前提
在我的博客园中我写了关于一些RDLC报表的使用,请参考这里。因为没有时间,所以没有导入到我的个人博客中。在博客园中相关文章如下:
[原创] RDLC 报表系列(一) 创建一个报表
[原创] RDLC 报表系列(二) 报表中插入图片
[原创] RDLC 报表系列(三) 参数、常量及常用表达式的使用
[原创] RDLC 报表系列(四) 子报表的使用
二、本文内容
加载RDLC报表数据
实现数据分组
总结
代码下载(下载)
三、加载RDLC报表数据
我们的示例是要从学生表中,取出200条学生信息,然后加载到RDLC报表中。
上面的代码已经获取到200条学生的信息,然后把数据从数据库中取出然后加载到StudentReport.rdlc报表中,下面要做的事情就是对数据进行分组了。
四、实现分组
下面我们根据学生的性别进行分组,步骤如下:
打开RDLC模板文件,点击报表的行标签,然后点击“插入分组(Insert Group)”
在插入分组的窗口中,我们选择需要分组字段(这里的学生的性别),如下图所示
插入分组后,我们可以为分组加一标题,标题就是性别
这样我们就已经分组结束了,下面我们要做的就是看看如果如何。
】
你也可以从这里下载PDF结果(下载)。
五、总结
通过上面的示例我们学会了如何使用RDLC分组功能实现功能,通过上面的示例我们插入了一个性别的分组,当然也可以分组中再插入子分组,以实现二级、三级或者N级分组。
当然可以对分组进行统计等一系列功能。
本文只代表作者在一定阶段的认识与理解。
一、写作前提
在我的博客园中我写了关于一些RDLC报表的使用,请参考这里。因为没有时间,所以没有导入到我的个人博客中。在博客园中相关文章如下:
[原创] RDLC 报表系列(一) 创建一个报表
[原创] RDLC 报表系列(二) 报表中插入图片
[原创] RDLC 报表系列(三) 参数、常量及常用表达式的使用
[原创] RDLC 报表系列(四) 子报表的使用
二、本文内容
加载RDLC报表数据
实现数据分组
总结
代码下载(下载)
三、加载RDLC报表数据
我们的示例是要从学生表中,取出200条学生信息,然后加载到RDLC报表中。
using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Data.SqlClient; using System.Collections.Generic; using System.Xml.Linq; using Microsoft.Reporting.WinForms; using RCLC.DataEntity; namespace RCLC { public partial class _Default : CustomPageBase { protected void Page_Load(object sender, EventArgs e) { } protected void ButtonReportGenerate_Click(object sender, EventArgs e) { List<ReportDataSource> reportDataSource = new List<ReportDataSource>(); RportDataSet ds = new RportDataSet(); string templatePath = string.Empty; string totalRecords = string.Empty; //获得数据 SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["LoggingConnectionString"].ConnectionString); SqlCommand command = conn.CreateCommand(); command.CommandType = CommandType.Text; command.CommandText = "SELECT TOP 200 * FROM T_STUDENT"; SqlDataAdapter da = new SqlDataAdapter(command); da.Fill(ds.T_STUDENT); //指定报表模板 templatePath = "ReportTemplate/StudentReport.rdlc"; //把获取的数据集合提供给在报表中名为RportDataSet_T_STUDENT数据集 reportDataSource.Add(new ReportDataSource("RportDataSet_T_STUDENT", ds.T_STUDENT)); List<ReportParameter> parameterList = new List<ReportParameter>(); ////Generate Report, 报表可以生成PDF,EXCEL及以其它形式,根据需求去设置 GetReportMultipleDataSourceFile(reportDataSource, templatePath, parameterList, "pdf"); } } }
上面的代码已经获取到200条学生的信息,然后把数据从数据库中取出然后加载到StudentReport.rdlc报表中,下面要做的事情就是对数据进行分组了。
四、实现分组
下面我们根据学生的性别进行分组,步骤如下:
打开RDLC模板文件,点击报表的行标签,然后点击“插入分组(Insert Group)”
在插入分组的窗口中,我们选择需要分组字段(这里的学生的性别),如下图所示
插入分组后,我们可以为分组加一标题,标题就是性别
这样我们就已经分组结束了,下面我们要做的就是看看如果如何。
】
你也可以从这里下载PDF结果(下载)。
五、总结
通过上面的示例我们学会了如何使用RDLC分组功能实现功能,通过上面的示例我们插入了一个性别的分组,当然也可以分组中再插入子分组,以实现二级、三级或者N级分组。
当然可以对分组进行统计等一系列功能。
相关文章推荐
- [原创] RDLC 报表系列(一) 创建一个报表
- RDLC报表系列--------行分组报表
- RDLC 报表系列(四) 子报表的使用
- [原创]Devexpress XtraReports 系列 3 创建主从报表
- [原创]Devexpress XtraReports 系列 8 创建Drill-Through报表
- rdlc 报表 分组排序
- [原创]Devexpress XtraReports 系列 2 创建表格报表
- rdlc 报表 矩阵 详解 分组、总计、表头、显示方向、序号
- RDLC报表系列(二) 行分组
- 微软BI 之SSRS 系列 - 使用 LookupSet 和 Adjacent Group 等高级技巧在报表中跨 Dataset 分组查询
- 为RDLC 报表分组添加序号
- RDLC报表 分组排序设置
- RDLC报表系列(六) 多图表-折线图和柱状图
- 动态生成rdlc 报表(原创)
- RDLC 报表系列(三) 参数、常量及常用表达式的使用
- RDLC报表系列(一) 简单的动态数据绑定和配置
- [原创]Devexpress XtraReports 系列 10 创建标签报表
- 微软BI 之SSRS 系列 - 使用分组 Group 属性实现基于父子递归关系的汇总报表
- asp.net 动态生成rdlc报表(原创)
- 【原创】StreamInsight查询系列(八)——基本查询操作之分组排序