Create Reports in Code

You can create reports in code when a layout should be generated dynamically and you cannot achieve this with built-in tools like conditional formatting or conditional visibility in a Report Designer. For example, a runtime-generated table report where columns are specified dynamically.

Code Samples

The following code samples illustrate how to generate reports in code:

The following topics describe the report object model and events:

Troubleshooting

If a runtime-generated report does not work correctly or you want to know how to implement a particular feature in code, follow these steps:

  1. Use the report's SaveLayoutToXml method to save the generated report as a REPX file.
  2. Add a new report to your .NET Framework project, expand the report's smart tag, and import the generated REPX file.

    Import a Report

  3. Specify the report's data source and preview the changes.

  4. Modify the report layout.
  5. The XtraReport.Designer.cs or XtraReport.Designer.vb file contains code that generates the report. Use this code in your application to get a similar result.