每当我预览报告时,我想在水晶报告中显示水印文本。为此,我创建了新段落对象,新字段(文本框)对象,然后使用 C# 以编程方式将其插入到水晶报表中,
下面是代码
CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument rptClientDoc1 = cryRpt.ReportClientDocument;
ISCRParagraphTextElement paragraphTextElement = new ParagraphTextElementClass();
paragraphTextElement.Text = "TESTING";
paragraphTextElement.Kind = CrParagraphElementKindEnum.crParagraphElementKindText;
ParagraphElements paragraphElements = new ParagraphElementsClass();
paragraphElements.Add(paragraphTextElement);
Paragraph paragraph = new ParagraphClass();
paragraph.Alignment = CrAlignmentEnum.crAlignmentHorizontalCenter;
paragraph.ParagraphElements = paragraphElements;
Paragraphs paragraphs = new ParagraphsClass();
paragraphs.Add(paragraph);
ISCRTextObject textObject = new TextObjectClass();
textObject.Paragraphs = paragraphs;
textObject.FontColor.Font.Bold = true;
textObject.FontColor.Font.Size = 48;
textObject.FontColor.Font.Italic = true;
textObject.FontColor.Color = uint.Parse(ColorTranslator.ToOle(Color.Gray).ToString());
textObject.FontColor.Font.Charset = 30;
textObject.Height = 8000;
textObject.Top = this.Height;
textObject.Left = 5000;
textObject.Width = 1500;
textObject.Format.TextRotationAngle = CrTextRotationAngleEnum.crRotationAngleRotate90;
ReportDefController2 reportDef = rptClientDoc1.ReportDefController;
ReportSectionController reportSectionController = rptClientDoc1.ReportDefController.ReportSectionController;
CrystalDecisions.ReportAppServer.ReportDefModel.Section newsec;
int index = reportDef.ReportDefinition.PageHeaderArea.Sections.Count;
if (index > 0)
{
newsec = reportDef.ReportDefinition.PageHeaderArea.Sections[index - 1];
}
else
{
index = 0;
newsec = reportDef.ReportDefinition.PageHeaderArea.Sections[index];
}
reportDef.ReportDefinition.PageHeaderArea.Sections.Insert(index, newsec);
CrystalDecisions.ReportAppServer.ReportDefModel.Section sectionToAddTo = reportDef.ReportDefinition.PageHeaderArea.Sections[index];
CrystalDecisions.ReportAppServer.ReportDefModel.SectionFormat newSectionFormat = sectionToAddTo.Format;
newSectionFormat.EnableKeepTogether = false;
newSectionFormat.EnableSuppress = false;
newSectionFormat.EnableUnderlaySection = true;
reportSectionController.SetProperty(sectionToAddTo, CrReportSectionPropertyEnum.crReportSectionPropertyFormat, newSectionFormat);
reportDef.ReportObjectController.Add(textObject, sectionToAddTo, 0);
这里的问题是PageHeader 中的新部分是 PageHeader中前一部分的副本,如果我更改PageHeader 属性中的新部分,它也会更改PageHeader 中的前一部分,请帮助我如何解决这个问题?