Visual Studio Report Designer
- 8 minutes to read
The Visual Studio Report Designer allows you to create platform-independent reports, preview them, and export to PDF, XLSX, and other formats.
The Report Designer is supported for .NET/.NET Core, .NET Framework, or .NET Standard projects. Refer to the following topic for more information: .NET/.NET Core Support.
Install the Report Designer
Use the DevExpress Unified Component Installer to install DevExpress components. These components include the Report Designer.
Invoke the Report Designer
The Report Designer is supported for Visual Studio projects of the following types:
- Class Library
- Console Application
- ASP.NET Web Forms
- ASP.NET MVC
- ASP.NET Core
- Blazor Server
To invoke the designer, create a project of a supported type and add a new report to this project as described in the following steps:
Press CTRL+SHIFT+A or click Project | Add New Item in the Visual Studio menu.
Select the DevExpress Report item, specify a report name, and click Add.
When you create a project that targets .NET/.NET Core, the DevExpress Report (.vsrepx) item is also available in the Add New Item window.
We recommend that you always choose the DevExpress Report item when you add a new report to your project. You can choose the DevExpress Report (.vsrepx) item if your project already contains reports stored in *.vsrepx files. See the following topic for more information on this file format, its use cases, and limitations: The VSREPX File Format.
Select the report type in the invoked Report Wizard and click Finish.
In .NET/.NET Core projects, a template for inherited reports is not supported in the Report Wizard. In such projects, you can inherit from a report only in code.
Use Report Designer Elements
After you invoke the Report Designer, the following elements appear in Visual Studio:
The Designer, Preview, and Scripts Tabs
The Preview tab allows you to generate and preview a report document.
In this tab, you can also do the following:
- Use the Parameters panel to specify values of report parameters.
- Save, print, export, or send the document by email.
- Configure page settings, scale, zoom, navigate the document.
- Setup a background color, specify a watermark.
In the Scripts tab, you can write code to do custom calculations over report data.
Refer to the following topic for more information: Scripts Overview.
The XtraReports Menu
Use the XtraReport menu to do the following:
- Enable/disable dock panels.
- Invoke the Report Designer Options window (Designer Options).
- Open the DevExpress Reporting online documentation (Learn More Online).
- Get information about your DevExpress subscription (About).
Field List – displays data fields available in the report’s data sources. You can drop each field onto the design surface to create a control bound to this field. You can also use the Field List to create, modify, or delete report parameters.
Report Explorer – displays a report structure in a tree-like form. Allows you to access report elements, rearrange them, change their settings, and add them to the Report Gallery as templates. You can also use the Report Explorer to add, modify, or delete report styles and report data sources.
Report Gallery – allows you to store and reuse reports and their elements.
Error List – shows errors, warnings, and information messages that describe the issues in your application.
Get Help on DevExpress Reporting API
You can open online documentation on a report control or its property from Visual Studio. Select a control in the Report Designer or click a property in the Properties window and press F1.
Refer to the following topic for more information: Get Help on DevExpress Reporting API.
Specify Report Settings
Use the Report Designer Options window to specify report design-time settings.
Localize a Report
The Report Designer includes the Localization Editor that allows you to localize a report.
Refer to the following topic for more details: Localization Editor (Visual Studio IDE).
Save a Report
You can save a report and import it to another project, or open the report in the End-User Report Designer.
Click a report’s smart tag and click Save.
In the invoked Save as dialog, specify a file name and type.
The saved report is stored in a *.repx file. You can save a report in XML (Report XML Files) or CodeDOM (Report Files) format. We recommend that you always store and distribute your reports in XML format. Refer to the following topic for more information: Store Report Layouts and Documents.
Import a Report
Click the report’s smart tag and select the Open/Import action.
Select a *.repx file in the invoked Import Report dialog.
In Visual Studio, you can also import reports produced by third-party vendors. Refer to the following topic for more information: Convert Third-Party Reports to DevExpress Reports.
Report Serialization Specifics
When you add a new report to a Visual Studio project, you can choose the DevExpress Report item or the DevExpress Report (.vsrepx) item (available only in projects that target .NET/.NET Core) in the Add New Item dialog.
Depending on your choice, the designer serializes your report in a .cs or .vsrepx file.
The CS File Format
If you choose the DevExpress Report item, the designer serializes the report in the following files:
- ReportName.Designer.cs – contains a report definition in the CodeDOM format. The designer generates code in this file automatically while you create a report.
- ReportName.cs – this file is intended for custom code. For example, the file can contain code of report event handlers.
- ReportName.resx – includes report resources.
We recommend that you always use the CS file format (choose the DevExpress Report item) to serialize a report in a Visual Studio project.
The VSREPX File Format
The VSREPX file format is a legacy format that was used for report serialization in the initial development stages of the Report Designer for .NET/.NET Core. You can choose the DevExpress Report (.vsrepx) item if you want to add a new report to the project that already contains reports stored in .vsrepx files. If you choose this item, the designer serializes the report to the following files:
- ReportName.Designer.cs - contains code that loads a report definition from a *.vsrepx file.
- ReportName.cs - stores custom code.
- ReportName.vsrepx - contains a report definition in XML-based format.
The following specifics apply to the .vsrepx file format:
The .vsrepx file format is the only format available for report serialization for .NET/.NET Core projects created in Visual Studio 2017.
You cannot use report inheritance if you store a report in a *.vsrepx file. Convert your *.vsrepx file to a *.cs file if you want to inherit from a *.vsrepx report. Refer to the following section for instructions: Convert a VSREPX File to a CS File.
*.vsrepx files should not be used as *.repx files. If you pass a *.vsrepx file to a report’s LoadLayoutFromXml method, the following exception occurs:
You cannot use the LoadLayoutFromXml method to open a Visual Studio Report Designer’s internal working file. Use the Save command in the Visual Studio Report Designer to create a standard report template (REPX) file.
If you want to use the LoadLayoutFromXml method to load a report definition from XML, save your report to a *.repx file and pass the saved file to this method.
Convert a VSREPX File to a CS File
- Open your project in Visual Studio and double-click a *.vsrepx file to invoke the Report Designer.
Save the report to a *.repx file.
Add a new blank *.cs report to your project.
Import the saved *.repx file to the new *.cs report.
If your report stored in a *.vsrepx file contains custom code, copy this code to the new *.cs report.
Work with a Report in Code
The Report Designer serializes your report while you create it in Visual Studio. This serialization mechanism allows you to create an instance of your report in code. You can then modify, export, or print the created report without showing its preview, or pass the report instance to the Document Viewer or the End-User Report Designer.
The following example creates a report instance and exports it to PDF:
using System; //.. var report = new XtraReport1(); report.ExportToPdf(Environment.GetFolderPath( Environment.SpecialFolder.UserProfile) + @"\Downloads\Report1.pdf" );
Refer to the following articles for more information: