Skip to main content Skip to footer

Export DataTemplate Column to Excel in C1DataGrid for WPF Edition | ComponentOne

Background:

While exporting C1DataGrid to Excel, data present in DataTemplateColumn is not exported by default.

Steps to Complete:

To save the data present in DataTemplate column, use GettingCellValue event of DataTemplate column:

private void DataGridTemplateColumn_GettingCellValue(object sender, C1.WPF.DataGrid.DataGridGettingCellValueEventArgs e)
{
      e.Value = ((TextBlock)(e.Row.Presenter[grid.Columns["TemplateCol"]].Content)).Text;
}

Ruchir Agarwal