zoukankan      html  css  js  c++  java
  • 动态创建报表笔记

    一、 新建XtraForm(可增加printBarManager1打印控件)

    二、引用类using DevExpress.XtraReports.UI;//使用报表属性需要用到该类

    //实例化打印报表
     public Reports.XtraReport_ZD rpt = new Reports.XtraReport_ZD();

    三、首先在XtraReportBase.Bands属性中添加Bands(添加带区)

    ReportHeaderBand header = new ReportHeaderBand();//表头(一次)
     //把带区加到报表中
    rpt.Bands.AddRange(new DevExpress.XtraReports.UI.Band[] { detail, header, pagefood, topM, ghBand });

    四、 在相应的Bands的XRControl.Controls属性中添加控件(往相应的带区添加控件)

    //新增控件,设定控件的属性
    XRLabel xlabRH = new XRLabel();
    xlabRH.Text = "表头";
    xlabRH.BackColor = Color.SeaGreen;
    xlabRH.Font = new Font(new System.Drawing.FontFamily("宋体"), 20, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
     xlabRH.Size = new Size(200, 42);//设置控件大小
    xlabRH.LocationF = new System.Drawing.Point(100, 500);
    //把控件添加到带区
    rpt.Bands[BandKind.ReportHeader].Controls.Add(xlabRH);
    View Code

    五、绑定数据

    rpt.DataSource = FillDataset();//设置报表数据源 
    rpt.DataMember = ((DataSet)rpt.DataSource).Tables[0].TableName;
    //给相应的控件赋值
    ..........
    //打开报表
    rpt.ShowPreviewDialog();
  • 相关阅读:
    pycharm初始配置
    个人Python笔记
    Linux硬盘分区
    Linux基础(三)
    Linux基础(二)
    linux基础之基本命令
    计算机网络基础
    计算机操作系统
    计算机基础
    vim编辑器
  • 原文地址:https://www.cnblogs.com/Garden-blog/p/3191338.html
Copyright © 2011-2022 走看看