I have serveral gridviews with observable collections as their items sources. I have a button which does an Excel export on the grids (by getting the item's sources). I would like the export to match whatever sorting the users applied on the grid. How can I accomplish this?
3 Answers, 1 is accepted
answered on 04 Oct 2012, 07:03 AM
The Export() method will export the data in the same order as you can see them sorted in the GridView. You can check our Exporting WPF demo for an example.
May I ask you to clarify what exactly do you mean by "the export to match whatever sorting the users applied"?
I am not using the Export function of the grid because the solution required the use of OpenXML to generate the Excel file. What I mean by "the export to match whatever sorting the users applied" is that I want the order of the rows in the Excel file to match the order on the grids once the users have sorted the grid in whatever way they like. Is there a way to get the sorted collection that is the source data for the grid? or get a list of columns on which the grid is being sorted?
answered on 05 Oct 2012, 05:26 AM
You use the grid Items collection to build your document. This collection will respect sorting, filtering, etc.