This example demonstrates how to dynamically create a report based upon the GridView extension at runtime. This means that all filtering, sorting and grouping conditions selected in the grid are also applied in a report. To accomplish this task, it is necessary to create a report with all the necessary bands, bind it to a data source and adjust all the necessary options. You can use this approach if you need to display content of templated columns in your report or insert a report based on GridView to another report.
As it is impossible to get the GridView extension state (its filtering, groping, sorting info), the Session is used to pass the last GridView state to the controller.
See also:
E4476: How to convert and then print an ASPxGridView by using the XtraReport
Question Comments
Added By: Kiran Pratapagiri at: 7/3/2013 12:46:27 AM
Hi,
Thanks for the example.
I think I found the problem with this example. It's not exporting the last column of the Grid.
Please correct the example to export the last column into report.
Thanks
Added By: Diogo Azevedo 1 at: 10/24/2013 8:23:13 AMthis example works for version 2012?
Added By: Vasily (DevExpress Support) at: 10/24/2013 11:31:20 PMYes, this example should work with version 2012. Anyway, if you face any issues after converting this example to version 2012, please feel free to create a separate support ticket for this issue.
Added By: Nick Hoare at: 7/22/2014 9:28:47 AMIn ReportHelper.vb, in InitDetailsandPageheader cell.Text is set to the FieldName where I think it should really be set to the ColumnCaption to make use of the work done in GetColumnsInfo which selects the ColumnCaption to be the Caption if there is one or FieldName if there isn't. It certainly works better for me. This affects C#, VB and ASPxGridView example code.
cell.Width = columns(i).ColumnWidth
cell.Text = columns(i).ColumnCaption 'Better to show the Caption than the examples columns(i).FieldName
row.Cells.Add(cell
Thank you for your feedback. This example demonstrates how to generate an XtraReport from ASPxGridView, so we will not change its code now.
Anyway, feel free to modify the code provided in this example according to your scenario.