• rdlc报表的制作步骤


     

    1、 新建报表文件(rdlc

    2、 配置数据源

    a)         不用数据源,只用传参数的方式。(参见示例)

    b)        在数据源中添加新的数据源(数据库,web服务以及对象)

    c)        在报表的同级目录下建立数据集文件(xsd)可以像数据表一样进行设计

    注:对b)项数据集中的表更名后之前的表名还留在其中,可以用文本编辑器打开rdlc文件,将DataSets中多余的DataSet删除。在实例化报表数据源时可使用

    ReportDataSource rds = new ReportDataSource(”MyReportDS_Users”, mrds.Tables["Users"]);

    其中

    MyReportDS为数据集文件名(xsd文件名)

    Users为DataTable的名字,整个为DataSet的名字。

    mrds.Tables["Users"] 为一个表对象,还可以是其他对象,具体请参加MSDN文档。

    ReportDataSource具有多个重载的构造函数。

    3、   实例化一个报表容器:ReportViewer

    示例代码
    ReportViewer  reportViewer = new ReportViewer();

    reportViewer.ProcessingMode 
    = ProcessingMode.Local;//表明控件配置为本地

    ReportParameter reportParameter1 
    = new ReportParameter("name""weiq");

    ReportParameter reportParameter2 
    = new ReportParameter("departmentId""123");

    List
    <ReportParameter> paraList = new List<ReportParameter>();

    paraList.Add(reportParameter1);

    paraList.Add(reportParameter2);

    String rootPath 
    = "Monster\\UI\\Report\\MyReportTest.rdlc";

    //System.IO.Path.Combine(FileService.RootPath, "Monster\\UI\\Report\\MyReportTest.rdlc");  

    //添加本地路径(可以是相对路径也可以是绝对路径)

    reportViewer.LocalReport.ReportPath 
    = rootPath;               reportViewer.LocalReport.DataSources.Add(new ReportDataSource("MyReportDS_Users", mrds.Tables["Users"]));

    reportViewer.LocalReport.SetParameters(paraList); 
    //添加参数

    // Add the reportviewer to the form

    reportViewer.Dock 
    = DockStyle.Fill;

    // Process and render the report

    this.Controls.Add(reportViewer);

    reportViewer.RefreshReport();


  • 相关阅读:
    sublime显示当前文件的编码格式
    关于jquery中html()、text()、val()的区别
    bit,Byte,B,KB,MB,GB
    python之序列操作
    编程常用密匙
    js数组操作
    ob函数的使用
    php使用zlib实现gzip压缩
    js兼容性汇总
    centos7下源码编译安装mysql5.7
  • 原文地址:https://www.cnblogs.com/aisini/p/1694097.html
Copyright © 2020-2023  润新知