標籤:報表 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基本操作賦值