RDLC系列之一 简介和入门

一、简介

  RDLC报表,通过Report Viewer Control来实现,制作微软RDLC报表由以下三部分构成:1.制作自己的DateSet集合(就是报表的数据集);2.制作自己的报表文件.rdlc文件,用于画做报表样式,里面有微软自带的导出和打印功能。制作显示报表的前台页面aspx文件,基本上就是插入一个ReportViewer然后关联上面的.rdlc文件,注意别忘了更新数据源和插入ScriptManager.

   这种报表的易用性和可定制性,主要功能:
       1、简单易用的控件,特别是Table控件,非常方便字段在报表上的排列;
       2、灵活的可定制性,用XML来描述一个报表相关的一切;
       3、高度可编程性,在你的项目中,甚至不需要有一个报表文件,通过代码就可以实现报表生成、预览和打印等一系列操作;
       4、支持DrillThrough数据钻取功能;
       5、导出的Excel文件格式非常完美,任何其它报表在这方面都不能与之比拟,而且并不需要安装Excel;

二、入门

一、效果图

二、过程图解

1.创建一个winform项目,添加报表控件

2.创建一个数据集

创建表

3.创建报表RDLC

4。添加数据集到报表

5.在rldc中添加表,指定列

6.参数

 

项目文件:

7.代码 

using Microsoft.Reporting.WinForms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

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

        private void Form1_Load(object sender, EventArgs e)
        {
            //自定义数据源
            DataTable dt = new DataTable();
            dt.Columns.Add("id", typeof(int));
            dt.Columns.Add("name", typeof(string));
            DataRow dr = null;
            dr = dt.NewRow();
            dr[0] = 1;
            dr[1] = "li";  
            dt.Rows.Add(dr);
            //自定义参数
            List<ReportParameter> list = new List<ReportParameter>();
            ReportParameter rp = new ReportParameter("pid", "11");
            list.Add(rp);

            this.reportViewer1.LocalReport.ReportPath = Application.StartupPath + "\\Report1.rdlc";
            this.reportViewer1.LocalReport.DataSources.Clear(); 
            this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", dt));//指定数据源
            this.reportViewer1.LocalReport.SetParameters(list); //参数设置 
            this.reportViewer1.RefreshReport();
        }
    }
}

 

图解:DataSet1为该名称,非数据源名称

 

 

 注意:rdlc文件属性

 

 

参照文章:

http://www.cnblogs.com/waxdoll/archive/2006/07/24/458409.html#!comments

http://waxdoll.cnblogs.com/archive/2006/02/25/337713.html

http://www.cnblogs.com/zhwl/p/3283924.html

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值