Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
saurabh_pathak
Active Contributor
0 Kudos

While designing the report we drop the required objects within the canvas/ layout of the report. Have we ever tried thought what is the proper name of it? How that can be found using .NET SDK?


Not many people who design the reports actually know that Crystal Reports has 5 prominent Areas - Report Header, Page Header, Details, Report Footer, and Page Footer. Group Header and Group Footer are added later only if group, summary, or subtotal is added to the report, which takes the count to 7.

 

When a group, summary, or subtotal is added, the Group Header area appears directly above the Details area and the Group Footer area appears directly below the Details area. (See the Output below)

The following is the code that has helped me find Areas in a Report, which has a sub-report, summary, subtotal and group etc…

Sample Code to Find Areas

private void FindAreas()

    {

        ReportDocument rd = new ReportDocument();

        string reportPath = Server.MapPath("CrystalReports.rpt");

        rd.Load(reportPath);

        ReportDefinition reportDefinition = rd.ReportDefinition;

        Areas areas = reportDefinition.Areas;

        if (areas.Count > 0)

        {

            Response.Write("</br>");

            Response.Write("</br>");

            Response.Write("<table border=1 cellspacing=2>");

            Response.Write("<tr>");

            Response.Write("<td><b>Area Format</b></td>");

            Response.Write("<td><b>Area Kind</b></td>");

            Response.Write("<td><b>Area Name</b></td>");

            Response.Write("<td><b>Section Name</b></td>");

            Response.Write("</tr>");

            foreach (Area area in areas)

            {

                Response.Write("<tr>");

                Response.Write("<td>" + area.AreaFormat.ToString() + " </td>");

                Response.Write("<td>" + area.Kind.ToString() + " </td>");

                Response.Write("<td>" + area.Name + " </td>");

                Response.Write("<td>" + area.Sections.ToString() + " </td>");

                Response.Write("</tr>");

            }

            Response.Write("</table>");

        }

    }

The output of the code is as follows:

My quest was to find the Areas using Crystal Reports .NET and the code has helped me achieve the same.

Labels in this area