ReportDocument Object Model

The ReportDocument class provides a more extensive object model for the SDK than the CrystalReportViewer object model.

ReportDocument class is part of the CrystalDecisions.CrystalReports.Engine namespace. It functions as a gateway to a set of classes in the Engine namespace, which provide more tools for programmatic manipulation of a report.

The ReportDocument Object Model

In the previous section, you learned how to work with the basic CrystalReportViewer object model by assigning a report path string directly to the CrystalReportViewer control. See CrystalReportViewer Object Model.

At the next level of the object model, you use the ReportDocument object model to encapsulate the report within an instance of ReportDocument, before it is assigned to the control. That provides access to the more complex and powerful object model provided in ReportDocument.

Note

Because both object models are involved in this process (CrystalReportViewer to load and display the report, ReportDocument to encapsulate and manipulate the report), it is easy to confuse the roles of the two object models. Once the ReportDocument object model has been used to encapsulate the report, all report manipulation must be restricted to that model. If you try to use the properties and methods of CrystalReportViewer to manipulate the report, the two object models conflict and generate unexpected behavior.

Once you have introduced an additional object model, restrict the use of CrystalReportViewer code to only set display properties.

For more information on how to choose an object model, see Which Object Model Should I Use?.

ReportDocument and ReportClientDocument (RAS)

In Crystal Reports 9, the two object models were completely separate. In Crystal Reports 10 and up, the fundamental separation between object models has been removed. The ReportDocument object model now functions as a proxy to (a subset of) functionality from the ReportClientDocument object model.

Crystal Reports 2008 allows you to access a limited version of the ReportClientDocument object model through the ReportDocument.ReportClientDocument property.

ReportDocument Object Model Diagram

This diagram shows the relationships of the ReportDocument object model.

Figure 3: ReportDocument Object Model

See Also