Skip to main content


Access to ReportObjects of SAP Crystal Reports Programmatically

When you intend to create report utilizing SAP Crystal Reports for Visual Studio 2012, generally speaking, all the report content can be bound with some kinds of data source (like DataSet). However, in some particular scenarios, some report content is not bound to any data source, and you have to change them dynamically, such as report title, report filter criterion, this post introduces you to change the report object attributes programmatically in Visual Studio 2012.

Using libraries:

using CrystalDecisions.Shared;

using CrystalDecisions.CrystalReports.Engine;

Then you need to find the section ID and report object ID in crystal report designer, the following piece of C# code can update the text of the report objects, such as report title, report footer and filter criterion:

ReportClass rpt = new MyReport();

((TextObject)rpt.ReportDefinition.Sections[2].ReportObjects[“Text_ReportTitle”]).Text = param.ReportTitle;

            ((TextObject)rpt.ReportDefinition.Sections[2].ReportObjects[“Text_ReportFooter”]).Text = param.ReportFooter;

            ((TextObject)rpt.ReportDefinition.Sections[2].ReportObjects[“Text_FilterParameters”]).Text = param.ReportQuery;

Also, you can access some other attributes like object position, height, width, suppress, background color and so on.

((TextObject)rpt.ReportDefinition.Sections[2].ReportObjects[“Text_Field1”]).Width = colWidth;

((TextObject)rpt.ReportDefinition.Sections[2].ReportObjects[“Text_Field1]).ObjectFormat.EnableSuppress = true;

((FieldObject)rpt.ReportDefinition.Sections[3].ReportObjects[“DataColumn1]).Height = colHeight;

 ((FieldObject)rpt.ReportDefinition.Sections[3].ReportObjects[“DataColumn1”]).ObjectFormat.EnableSuppress = true;

There are good hints in case you need to create dynamic crystal report with SAP Crystal Report for Visual Studio 2012.

Thoughts on “Access to ReportObjects of SAP Crystal Reports Programmatically”

  1. I need to extract detail data from a Crystal report after the report is run.
    For each detail row, I need to extract the output of the formulas.
    Following your process here, I can access the text of the formula, but I need the value that the formula will evaluate to.

    Any idea how I can go about getting the formula output for each row in the detail section of a report?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Richard Yang

More from this Author

Follow Us