• 1.从工具箱拉出表或者矩阵(本次使用的是矩阵)

  • 2.选择需要的数据集,没有就新建一个数据集,名称自己起好,下面有用到

  • 3.将行组和行列显示出来(右击报表--试图=>)

  • 4.双击行组下的RowGroup组=>常规=>组表达式=>分组方式,点击FX 选择类别=>字段(DbSetName)=>双击右边的值(选择你要的分组依据),或者直接点击页面矩阵上行右上角的图标添加分组依据(第3步图)。
  • 5.右击行组--RowGroup组,添加组=>子组,同第3步一样 fx 之后的步骤

6.如果在这个组下有其他数据要展示,右击你添加好的行组所在视图的文本框=>插入列=>组内部-右侧(位置左右自己挑)

                              7.后台代码

var list=XXX,在数据层拿到T-SQL数据

直接输出为PDF下载到本地

excel格式: 

  var bytes = viewer.LocalReport.Render("Pdf")中把 “PDF”替换”EXCEL“;

      Response.ContentEncoding = Encoding.GetEncoding("GB2312"); 把 “GB2312”替换"application/vnd.ms-excel";
              

   protected void Page_Load(object sender, EventArgs e)
{ if (IsPostBack) return;
try
{
var list = new reportBL().report();
if (list.Count == )
{
Response.Write("没有信息!");
return;
}
DataTable dt = ListToDataTable(list);
var viewer = new ReportViewer();
viewer.LocalReport.ReportPath = @"Rpt\Rdlc\SampleForm.rdlc";
viewer.ProcessingMode = ProcessingMode.Local;
//这里把建好的数据集的名称替换掉DataSetName
var rds = new ReportDataSource("DataSetName", dt);
viewer.LocalReport.EnableExternalImages = true;
viewer.LocalReport.DataSources.Clear();
viewer.LocalReport.DataSources.Add(rds);
viewer.LocalReport.EnableExternalImages = true;
errCode = ;
viewer.LocalReport.Refresh();
var bytes = viewer.LocalReport.Render("Pdf");
errCode = ;
Response.ContentType = "application/pdf";
//设定编码方式,若输出的excel有乱码,可优先从编码方面解决
Response.Charset = "gb2312";
//Response.Charset = "utf-8";
Response.ContentEncoding = Encoding.GetEncoding("GB2312");
//关闭ViewState,此属性在Page中
EnableViewState = false;
//filenames是自定义的文件名
Response.AppendHeader("Content-Disposition", string.Format("attachment;filename={0}.pdf", DateTime.Now.ToString("yyyyMMddHHmmssffff")));
//content是步骤1的html,注意是string类型
Response.BinaryWrite(bytes);
Response.End(); }
catch (Exception ex)
{ Response.Write(ex.Message + ":" + errCode);
} }
public static DataTable ListToDataTable<T>(IList<T> list, params string[] propertyName)
{
var propertyNameList = new List<string>();
if (propertyName != null)
propertyNameList.AddRange(propertyName);
var result = new DataTable();
if (list.Count > )
{
PropertyInfo[] propertys = list[].GetType().GetProperties();
foreach (PropertyInfo pi in propertys)
{
if (propertyNameList.Count == )
{
DataColumn dc = new DataColumn();
dc.AllowDBNull = true;
dc.ColumnName = pi.Name;
dc.DataType = pi.PropertyType;
result.Columns.Add(dc);
}
else
{
if (propertyNameList.Contains(pi.Name))
result.Columns.Add(pi.Name, pi.PropertyType);
}
} for (var i = ; i < list.Count; i++)
{
var tempList = new ArrayList();
foreach (PropertyInfo pi in propertys)
{
if (propertyNameList.Count == )
{
object obj = pi.GetValue(list[i], null);
tempList.Add(obj);
}
else
{
if (propertyNameList.Contains(pi.Name))
{
var obj = pi.GetValue(list[i], null);
tempList.Add(obj);
}
}
}
object[] array = tempList.ToArray();
result.LoadDataRow(array, true);
}
}
return result;
}

Rdlc报表 数据汇总分组展示的更多相关文章

  1. RDLC报表系列--------行分组报表

    报表分组开发步骤: 先看总体效果:如图 下面就做个看看... 1.先将数据处理成如下结构 如图 2.创建数据集DataSet.xsd,创建表->右键选择添加数据表->添加行(ctrl+L ...

  2. ASP.NET MVC应用程序展示RDLC报表

    原文:ASP.NET MVC应用程序展示RDLC报表 学习ASP.NET MVC这样久,在学习,练习与应用过程中,觉得很多知识与以前的ASP.NET多有区别,但是实现操作起来,细处又有许多相近的地方. ...

  3. 在mvc视图中实现rdlc报表展示(补充)

    上篇: 在mvc视图中实现rdlc报表展示 在上一遍中,由于不知道如何在aspx.cs后台中实例化abp的IxxxAppService.cs的接口,我采取的方式是在视图页中把查询出的数据存储到aspx ...

  4. 在mvc视图中实现rdlc报表展示

    需求:在view视图页面中嵌入rdlc报表,rdlc的xml为动态传入的xml字符串.本项目是基于abp框架 可能出现问题: 1.rdlc报表是由asp.net的服务器控件ReportViewer来支 ...

  5. 动态生成RDLC报表

    前段时间,做了RDLC报表,主要是三块功能: 1.从DataGrid提取(包括最新的增删改)的数据,自动生成对应的RDLC报表文件(以流的形式驻存在内存中),用ReportViewer类来展示.打印. ...

  6. DevExpress的XtraReport和微软RDLC报表的使用和对比

    我们开发程序的时候,经常会碰到一些报表,如果是Winform的报表,一般可以采用DevExpress控件组的XtraReport,或者微软的RDLC报表,当然还有一些其他的,在此不再赘述.由于本人在W ...

  7. .Net SSRS(rdlc) 报表经验总结

    排版 1. 可以利用表格来布局,以避免调整固定宽度的麻烦. 2. 一个表的表头里还可以嵌套表格. 3. 设置rdlc报表打印格式.首先打开RDLC报表设计器页面.在灰色部分点右键 -> 报表属性 ...

  8. RDLC报表系列(一) 简单的动态数据绑定和配置

    RDLC系列链接 RDLC报表系列(一) 简单的动态数据绑定和配置  RDLC报表系列(二) 行分组 RDLC报表系列(三) 总计和折叠 RDLC报表系列(四) 矩阵 RDLC报表系列(五) 简单的图 ...

  9. rdlc报表随笔心得 ,基本结构和一些表达式。

    Dataset Form RDLC 主要放数据集的文件夹 存放窗体的文件夹 存放各种报表的文件夹 第一部,创建报表结构 首先添加数据集项 添加完成之后我们会看到这个页面 之后我们在上面添加一些数据集 ...

随机推荐

  1. mpt_voronoi demo

    % %demo1% A=rand(3,10);% pbound=Polyhedron([0 0 0;150 0 0;150 150 0;0 150 0; 0 0 1;150 0 1;150 150 1 ...

  2. HDU5870 Alice's Adventure in Wonderland

    大概做法是这样的 考虑最朴素的做法,预处理出1到所有点的最短路数组dis1和方案数数组cnt1,和预处理出n到所有点的最短路数组dis2和方案数数组出cnt2,然后暴力枚举点对(A,B),如果A和B之 ...

  3. (一)GPIO 编程实验 LED 流水灯控制

    7个寄存器 是R1-R16.(当然,里面有很多是分几个模式的,所以总共有37个)类似于单片机的R0-R7. GPXCON,GPXDAT等等是另外的寄存器,应该叫,特殊功能寄存器,类似于单片机的P0,P ...

  4. javaSE基础第二篇

    1.JDK下载: www.oracle.com   2.JAVA_HOME bin目录:存放可执行文件.exe 把可能变的路径写入JAVA_HOME path=......;%JAVA_HOME%%; ...

  5. iframe

    var ifr = document.getElementById('ifr'); var win = ifr.window || ifr.contentWindow; win.a(); // 调用i ...

  6. ajaxfileupload 传参数

    引用:http://www.cnblogs.com/lyeo/archive/2012/05/11/2496261.html 直接上代码: var data = { name: 'my name', ...

  7. 学习js回调函数

    <!DOCTYPE HTML> <html> <head> <meta charset="GBK" /> <title> ...

  8. 如何使用iTunes与iTools导出微信聊天记录

    .tocblock .tocblock .tocblock { margin-left: 2.25em; } .madoko .toc>.tocblock .tocblock { margin- ...

  9. htm5l,第一个script代码练习

    <body>    <canvas id="mycanvas" width="500" height="300">  ...

  10. java文件编程总结

    文件编程之一就是文件操作,就是新建,删除,复制,更名 新建文件用createNewFile()方法,要处理IOException异常 新建文件夹用mkdirs()方法 删除一个文件和一个空的文件夹直接 ...