Home Forums WinForms controls Xceed Grid for WinForms Export to Excel Reply To: Export to Excel

User (Old forums)
Member
Post count: 23064

In fact, the true bug here is that not all the details are exported…  Since version 3.7 we have added a feature which delays the rows creation in the detail grids up to the time they are expanded.  It results in the behavior you reported.

To fix this, we would need to add a property on the ExcelExporter like “OnlyExportExpandedDetails”.  When set to false, ALL details rows are created and exported.  When set to true, only those actually expanded are exported.

So we have added this as a feature request, but I can’t tell when this will be available.

Meanwhile, a workaround is to dynamically bind the detail grid when it expands.  To do this, you need to add an unbound DetailGridTemplate to the grid, and subscribe to its CollapsedChanged event.

In the event handler, when the detail grid is expanding, you need to bind to its ParentDataRow.Cells[ “RelationName” ].Value property, and when the detail grid collapse, set the binding to null.

 e.g. :

      if( !grid.Collapsed )
        grid.SetDataBinding( grid.ParentDataRow.Cells[ “SuppliersProducts” ].Value, string.Empty );
      else
        grid.SetDataBinding( null, string.Empty );     

I have attached a sample application demonstrating this.  On Vista, is should work as is.  On XP, you will need to change the connection string for the Northwind DB (which our package installs in [CommonAppDataFolder]\Xceed Software\Sample Data, which is the All Users Application Data folder path).

 

Imported from legacy forums. Posted by André (had 986 views)