码迷,mamicode.com
首页 > Windows程序 > 详细

c#report基本操作赋值

时间:2018-05-05 11:54:54      阅读:524      评论:0      收藏:0      [点我收藏+]

标签:报表   code   repo   lis   oca   mod   指定   style   pat   

 //第一步:清除之前的数据
  this.rptView.LocalReport.DataSources.Clear();
  //第二步:指定报表路径
  this.rptView.LocalReport.ReportPath = "Report2.rdlc";
  //第三步:构造新的DataTable
  DataTable dt = new DataTable("DataTable1");
  dt.Columns.Add("Name");
  dt.Columns.Add("Score");
  dt.Columns.Add("Id");
  dt.Rows.Add(new object[] { "语文", 80, "Y0001" });
  dt.Rows.Add(new object[] { "数学", 75, "S0001" });
  dt.Rows.Add(new object[] { "英文", 96, "E0001" });
  //名称不能写错,和报表中的数据集名称一致
  ReportDataSource rdsItem = new ReportDataSource("DataSet1", dt);
  //此处可以有多个数据源
  this.rptView.LocalReport.DataSources.Add(rdsItem);
  //第四步:构造参数
  List<ReportParameter> lstParameter = new List<ReportParameter>() {
                new ReportParameter("Title",this.txtTitle.Text),
                new ReportParameter("Id",this.txtId.Text),
                 new ReportParameter("Name",this.txtName.Text),
                new ReportParameter("Age",this.txtAge.Text),
                new ReportParameter("Sex",this.txtSex.Text),
                 new ReportParameter("Salary",this.txtSalary.Text),
                new ReportParameter("Depart",this.txtDepart.Text)
   };
  this.rptView.LocalReport.SetParameters(lstParameter);
  this.rptView.ZoomMode = ZoomMode.Percent;
  this.rptView.ZoomPercent = 100;
  //第五步:刷新报表
  this.rptView.RefreshReport();

 

c#report基本操作赋值

标签:报表   code   repo   lis   oca   mod   指定   style   pat   

原文地址:https://www.cnblogs.com/YuanDong1314/p/8994194.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!