zoukankan      html  css  js  c++  java
  • 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();


  • 相关阅读:
    如何查看 SQL Server 执行的历史 SQL 语句记录?
    C# 父子窗体 传值
    java使用HttpURLConnection和HttpClient分别模拟get和post请求以及操作cookies
    selenium使用等待的几种方式
    初识selenium-grid
    selenium如何分别启动IE、firefox、chrome浏览器
    java在url传输前更改字符编码
    java获取Json和http状态码
    testng环境设置
    使用reportNG替换testNG的默认报告
  • 原文地址:https://www.cnblogs.com/aisini/p/1694097.html
Copyright © 2011-2022 走看看