Convert DevExpress Data Grid to Report
This document describes how to convert a DevExpress Grid control to a report.
Convert WinForms DevExpress Grid
Use the ReportGenerator component to convert the GridControl to the DevExpress report:
Review the Advanced Grid Printing and Exporting topic for more information.
Convert WPF Data Grid
The Grid-based Report Generation converts the WPF Grid Control to a report with the same data, design, and layout.
Follow the steps below to add a bar or ribbon item that generates a grid-based report.
- Reference the DevExpress.Xpf.ReportDesigner.v24.2.dll assembly.
- Attach the GridReportManagerService to a TableView.
- Attach the ReportManagerBehavior to a ribbon or bar item.
- Bind the ribbon or bar item’s ReportManagerBehavior.Service property to the GridReportManagerService.
The following XAML snippet illustrates this approach:
<dx:ThemedWindow
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars"
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
xmlns:dxrudex="http://schemas.devexpress.com/winfx/2008/xaml/reports/userdesignerextensions"
xmlns:local="clr-namespace:ReportFromGrid"
x:Class="ReportFromGrid.MainWindow"
Title="Convert Grid to Report" Height="800" Width="1000">
<DockPanel>
<dxb:ToolBarControl DockPanel.Dock="Top" >
<dxb:BarSplitButtonItem Glyph="{dx:DXImage Image=Print_16x16.png}">
<dxmvvm:Interaction.Behaviors>
<dxrudex:ReportManagerBehavior Service="{Binding ElementName=reportManagerService}"/>
</dxmvvm:Interaction.Behaviors>
</dxb:BarSplitButtonItem>
</dxb:ToolBarControl>
<dxg:GridControl AutoGenerateColumns="AddNew" EnableSmartColumnsGeneration="True">
<dxg:GridControl.View>
<dxg:TableView ShowTotalSummary="True">
<dxmvvm:Interaction.Behaviors>
<dxrudex:GridReportManagerService x:Name="reportManagerService" />
</dxmvvm:Interaction.Behaviors>
</dxg:TableView>
</dxg:GridControl.View>
</dxg:GridControl>
</DockPanel>
</dx:ThemedWindow>
Refer to the Grid-Based Report Generation article for more information.