文字解释丢失

2020-08-21 10:21发布

点击此处---> 群内免费提供SAP练习系统(在群公告中)加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)嗨, 当我更改文本对象内的段落...

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


嗨,

当我更改文本对象内的段落文本元素的文本时,我丢失了该文本对象内所有字段的文本解释(RTF文本,HTML文本)。

实际上,当我读取段落字段元素的文本格式时,无论我在设计模式下进行了什么设置,我总会得到" crTextFormatStandardText"。 并且所做的任何修改均不适用。

我正在测试13.0.26版。

使用ReportDefModel = CrystalDecisions.ReportAppServer.ReportDefModel;

 私人无效测试()
         {
             CrystalDecisions.CrystalReports.Engine.ReportDocument reportDocument = crystalReportViewer1.ReportSource作为CrystalDecisions.CrystalReports.Engine.ReportDocument;

             foreach(reportDocument.ReportClientDocument.ReportDefController.ReportObjectController.GetReportObjectsByKind(ReportDefModel.CrReportObjectKindEnum.crReportObjectKindText)中的ReportDefModel.ISCRReportObject reportObject)
             {
                 ReportDefModel.TextObject textObject = reportObject作为ReportDefModel.TextObject;

                 foreach(textObject.Paragraphs中的ReportDefModel.Paragraph段落)
                     foreach(在段落.ParagraphElements中为ReportDefModel.ParagraphElement段落元素)
                         开关(paragraphElement.Kind)
                         {
                             案例ReportDefModel.CrParagraphElementKindEnum.crParagraphElementKindText:
                                 ReportDefModel.ParagraphTextElement段落文本元素=段落元素为ReportDefModel.ParagraphTextElement;

                                 段落TextElement.Text ="新文本";

                               /**
                                  *这会使我失去文本对象内所有字段对象的文本解释(RTF文本,HTML文本)
                                  */
                                 reportDocument.ReportClientDocument.ReportDefController.ReportObjectController.Modify(textObject,textObject);
                                 打破;
                             案例ReportDefModel.CrParagraphElementKindEnum.crParagraphElementKindField:
                                 ReportDefModel.ParagraphFieldElement段落字段元素=段落元素为ReportDefModel.ParagraphFieldElement;

                               /**
                                  *在设计模式下,我已将所有带有文本解释的字段对象设置为HTML文本,但是
                                  *段落字段元素。字段格式。字符串格式。文本格式返回crTextFormatStandardText
                                  *我将设置为crTextFormatHTMLText
                                  */
                                 段落FieldElement.FieldFormat.StringFormat.TextFormat = ReportDefModel.CrTextFormatEnum.crTextFormatHTMLText;

                               /**
                                  *这会使我失去文本对象内所有字段对象的文本解释(RTF文本,HTML文本)
                                  *我已将其设置为crTextFormatHTMLText,但没有任何效果
                                  */
                                 reportDocument.ReportClientDocument.ReportDefController.ReportObjectController.Modify(textObject,textObject);
                                 打破;
                         }
             }
         } 

是否可以在不丢失其他ParagraphFieldElement的文本解释的情况下更改ParagraphTextElement内部的文本?

此致

Marco Monteiro

15条回答
木偶小白
2020-08-21 10:47

我尝试替换为Modify:

 ReportDefModel.ISCRReportObject reportObjectNEW = reportObjectOLD.Clone();
 reportDocument.ReportClientDocument.ReportDefController.ReportObjectController.Modify(reportObjectOLD,reportObjectNEW); 

并且文本解释丢失了。

我还尝试用"删除/添加"代替

 ReportDefModel.ISCRReportObject reportObjectNEW = reportObjectOLD.Clone();
 reportDocument.ReportClientDocument.ReportDefController.ReportObjectController.Remove(reportObjectOLD);
 reportDocument.ReportClientDocument.ReportDefController.ReportObjectController.Add(reportObjectNEW,reportDocument.ReportClientDocument.ReportDefController.ReportDefinition.FindSectionByName(reportObjectOLD.SectionName)); 

和文本解释丢失了。

你能告诉我它是否适合你吗?

一周热门 更多>