I am utilizing the RadGridView's export to Excel functionality, and I have encountered an issue where the footer of my grid is not being exported correctly.
In my implementation, I have a Footer for the GridViewDataColumn that uses a TextBlock control, and I have applied a binding to the Text property of this TextBlock. This TextBlock shows up perfectly when viewing the grid within the application. However, when I export the grid to Excel, the content of the TextBlock from the Footer appears in the Excel file as "System.Windows.Controls.TextBlock" rather than the actual expected value.
Here is the XAML for the GridViewDataColumn footer:
<telerik:GridViewDataColumn.Footer>
<TextBlock
Text="{Binding Path=ItemsSource, RelativeSource={RelativeSource AncestorType=telerik:RadGridView}, Converter={StaticResource QiYesValueToCountConverter}, ConverterParameter=IK_2_1_2, UpdateSourceTrigger=PropertyChanged}"
FontSize="20"
ToolTip="{Binding ElementName=UserControl1, Path=DataContext.IkItemsSummary.IK_2_1_2}" />
</telerik:GridViewDataColumn.Footer>
And here is the method I use for the export:
private void ButtonBase_OnClick(object sender, RoutedEventArgs e) { string extension = "xlsx"; SaveFileDialog dialog = new SaveFileDialog() { DefaultExt = extension, Filter = String.Format("{1} Dateien (*.{0})|*.{0}", extension, "Excel"), FilterIndex = 1, FileName = "QI-Auswertungen" }; if (dialog.ShowDialog() == true) { using (Stream stream = dialog.OpenFile()) { RadGridView1.ExportToXlsx(stream); } } }
I have tried a few potential solutions, such as using a ContentControl instead of a TextBlock and tried using the ElementExporting and ElementExported events to manipulate the exported value directly. However, I am still facing the same issue.