网站建议:179001057@qq.com

c# 动态修改水晶报表文本内容

技术2022-05-11  2

using CrystalDecisions.CrystalReports.Engine; private const string REPORT_NAME = @"../../CrystalReportAnalysis.rpt"; private const string TEXT_OBJECT_NAME = @"Text1"; private void Form1_Load(object sender, System.EventArgs e) { report = new ReportDocument(); report.Load(REPORT_NAME); report.Refresh(); crvChart.ReportSource = report; } private void btnChangeText_Click(object sender, System.EventArgs e) { TextObject text; text = GetTextObject(TEXT_OBJECT_NAME); text.Text = "Hello, Haibo.NET!"; crvChart.RefreshReport(); } private TextObject GetTextObject(string reportObjectName) { TextObject text; // 按名称获取 ReportObject,将其转换为 TextObject, //并返回此对象。 text = report.ReportDefinition.ReportObjects[reportObjectName] as TextObject; if (text != null) return text; else return null; }  


最新回复(0)