Following the example in the Samples Browser, I am exporting my XamDataGrid to excel. However, exported document contains 13 extra collapsible rows in between each record showing what I assume are the original values (which I hid on the actual grid by setting ExpansionIndicatorDisplayMode="Never"). Is there any way to keep these original values from being exported to excel?
Thanks!
Hi Stephen,
If you want to keep those rows from exporting you can handle the RecordExporting event on the DataPresenterExcelExporter and cancel it for records you don't want exported. The event will provide you with the record it is currently going to export.http://help.infragistics.com/doc/WPF/2015.1/CLR4.0/?page=InfragisticsWPF4.DataPresenter.ExcelExporter.v15.1~Infragistics.Windows.DataPresenter.ExcelExporter.DataPresenterExcelExporter~RecordExporting_EV.html
There is also a CellExporting event that you can handle if you want to cancel certain cells and keep them from being exported.
Hi Rob,
Thank you for your quick reply! I was able to make some progress using the events you mentioned (see the code below). However, I am still getting several collapsible blank rows in between each record (see attached screenshot). Do you have any ideas on how to keep these from being exported?
Thank you!
Note: In my data set I know that any record with less than 18 cells or fields is not part of the data I want to export.
private void Exporter_HeaderAreaExporting(object sender, HeaderAreaExportingEventArgs e) { if(e.FieldLayout.Fields.Count < 18) { e.Cancel = true; } } private void Exporter_RecordExporting(object sender, RecordExportingEventArgs e) { if(((DataRecord)e.Record).Cells.Count < 18) { e.Cancel = true; } }
Those left over rows that you see are a result of the export option "ChildRecordCollectionSpacing". This setting adds space between the parent rows and their child rows. Set this setting to 0 if you want to remove that space.
This setting is inside the ExportOptions class which is an argument to the DataPresenterExcelExporter.Export method.
This solved my problem. Thank you for your help!