1298199 - How to add a section using the Crystal Reports .NET inproc RAS SDK

SAP Knowledge Base Article - Public

1298199 - How to add a section using the Crystal Reports .NET inproc RAS SDK

Symptom

How to add a section using the Crystal Reports .NET inproc RAS SDK ?

Reproducing the Issue

  • Crystal Reports XI Release 2 SP2 and later
  • C#
  • Resolution

    sample code:


               using CrystalDecisions.CrystalReports.Engine;
               using CrystalDecisions.ReportAppServer.ClientDoc;


               ReportDocument                                                                                    m_boReportDocument;
               ISCDReportClientDocument                                                                 m_boReportClientDocument;

               CrystalDecisions.ReportAppServer.ReportDefModel.Section        m_boSection;
               CrystalDecisions.ReportAppServer.ReportDefModel.ISCRArea    m_boArea;
          
                //create a new ReportDocument
                m_boReportDocument = new ReportDocument();

                //load the RPT file
                m_boReportDocument.Load("..\\..\\AddSection.rpt");

                //access the ReportClientDocument in the ReportDocument (EROM bridge)
               m_boReportClientDocument = m_boReportDocument.ReportClientDocument;

               //first determine where to add - in this case the details Area
               m_boArea = m_boReportClientDocument.ReportDefController.ReportDefinition.DetailArea;

               //create the new section object
               m_boSection = new CrystalDecisions.ReportAppServer.ReportDefModel.Section();

               //set the properties for the section
               m_boSection.Kind = CrystalDecisions.ReportAppServer.ReportDefModel.CrAreaSectionKindEnum.crAreaSectionKindDetail;
               m_boSection.Name = "Detail2";
               m_boSection.Height = 200;
               m_boSection.Width = 11520;

               //now add the section
               m_boReportClientDocument.ReportDefController.ReportSectionController.Add(m_boSection, m_boArea, -1);
              
               //display in reportviewer
               crystalReportViewer1.ReportSource = m_boReportDocument;

    Keywords

    How add section Crystal Reports .NET inproc RAS SDK , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , How To

    Product

    SAP Crystal Reports XI R2