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:
- Create a Simple Static Report (Runtime Sample)
- Create a Simple Data-Bound Report (Runtime Sample)
- Create a Master-Detail Report (Runtime Sample)
- Create a Cross-Tab Report (Runtime Sample)
- Create a Table Report with Dynamic Columns
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:
- Use the report’s SaveLayoutToXml method to save the generated report as a REPX file.
Add a new report to your .NET Framework project, expand the report’s smart tag, and import the generated REPX file.
Specify the report’s data source and preview the changes.
- Modify the report layout.
- The
XtraReport.Designer.cs
orXtraReport.Designer.vb
file contains code that generates the report. Use this code in your application to get a similar result.