1297305 - How to add a line to a report using the Crystal Reports .NET inproc RAS SDK

SAP Knowledge Base Article - Public

1297305 - How to add a line to a report using the Crystal Reports .NET inproc RAS SDK

Symptom

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

Reproducing the Issue

  • .NET Visual Studio 2005
  • C#
  • Resolution

    sample code :


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

            ReportDocument                                                                                  m_boReportDocument;
            ISCDReportClientDocument                                                               m_boReportClientDocument;

            CrystalDecisions.ReportAppServer.ReportDefModel.Section       m_boSectionStart;
            CrystalDecisions.ReportAppServer.ReportDefModel.Section       m_boSectionEnd;
            CrystalDecisions.ReportAppServer.ReportDefModel.LineObject  m_boLineObject;

            //create a new ReportDocument
            m_boReportDocument = new ReportDocument();

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

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

            //first determine the sections to start and end on - in this case the page header area
            m_boSectionStart = boReportClientDocument.ReportDefController.ReportDefinition.PageHeaderArea.Sections[0];
            m_boSectionEnd = boReportClientDocument.ReportDefController.ReportDefinition.PageHeaderArea.Sections[0];

            //create a new line Object 
            m_boLineObject = new CrystalDecisions.ReportAppServer.ReportDefModel.LineObject();

            //set it's properties  -  NOTE: only horizontal or vertical lines are popssible !!
            m_boLineObject.Right = 10000;
            m_boLineObject.Bottom = 10;
            m_boLineObject.Left = 10;
            m_boLineObject.Top = 10;
            m_boLineObject.LineThickness = 15;
            m_boLineObject.LineStyle = CrystalDecisions.ReportAppServer.ReportDefModel.CrLineStyleEnum.crLineStyleSingle;
            m_boLineObject.SectionName = m_boSectionStart.Name;
            m_boLineObject.EndSectionName = m_boSectionEnd.Name;

             //does this go into other sections
             m_boLineObject.EnableExtendToBottomOfSection = false;

             //set the section code for the section it is being added to
             m_boLineObject.SectionCode = m_boSectionStart.SectionCode;

             //add to the report
             m_boReportClientDocument.ReportDefController.ReportObjectController.Add(m_boLineObject, m_boSectionStart, -1);


             //display in reportviewer
             crystalReportViewer1.ReportSource = m_boReportDocument;

    See Also

     

     

    Keywords

    How add line Crystal Reports .NET inproc RAS SDK , KBA , BI-DEV-NET-SDK , .NET SDK / COM SDK , How To

    Product

    Crystal Reports 2008 V1 ; SAP Crystal Reports, developer version for Microsoft Visual Studio