I have got an issue when copying to excel from grid using custom Header. The grid has custom headers similar to below
<telerik:GridViewDataColumn x:Name="name1">
<telerik:GridViewDataColumn.Header>
<Grid>
<textBlock text = "header1"/>
...
</Grid>
When the data is pasted into excel it prints the name of the column as Grid ( to string invoked on the header). I tried using CopyingCellClipboardContent event but that only fires for cell values and not for header copying. I wanted to give my custom header names to be copied across to excel. How can i do that?
Thanks
Avneesh
<telerik:GridViewDataColumn x:Name="name1">
<telerik:GridViewDataColumn.Header>
<Grid>
<textBlock text = "header1"/>
...
</Grid>
When the data is pasted into excel it prints the name of the column as Grid ( to string invoked on the header). I tried using CopyingCellClipboardContent event but that only fires for cell values and not for header copying. I wanted to give my custom header names to be copied across to excel. How can i do that?
Thanks
Avneesh
5 Answers, 1 is accepted
0
Hi Avneesh,
Didie
Telerik
You can check our online documentation on the same matter.
Let me know how this works for you.
Didie
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0

Steve
Top achievements
Rank 1
answered on 05 Mar 2018, 08:50 PM
I am trying to follow the example in the online documentation and it doesn't work, the ElementExporting never gets called.
0
Hello Steve,
Can you please specify which export method you're using?
As specified in the Export Events article, when you call the Export method of RadGridView the ElementExporting and ElementExported events are fired. If you are using the more recently introduced ExportToXlsx and ExportToPdf methods, you should take advantage of the ElementExportingToDocument and ElementExportedToDocument events.
I hope you find this information helpful.
Regards,
Dilyan Traykov
Progress Telerik
Can you please specify which export method you're using?
As specified in the Export Events article, when you call the Export method of RadGridView the ElementExporting and ElementExported events are fired. If you are using the more recently introduced ExportToXlsx and ExportToPdf methods, you should take advantage of the ElementExportingToDocument and ElementExportedToDocument events.
I hope you find this information helpful.
Regards,
Dilyan Traykov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0

Steve
Top achievements
Rank 1
answered on 07 Mar 2018, 08:12 PM
I am not exporting, I am copying to Excel as the OP said. Select cells, copy, then paste in Excel, and an getting "textblock" as the output. I went through the same process as the OP, trying to use the CopyingCellClipboardContent function but it doesn't get called for headers.
The response in this thread was to use the ElementExporting, so I tried it and it did not work. Presumably you guys were just mistaken about using that method when copying and the OP just never followed up.
So the question remains, HOW to intercept the HEADER during the COPY and provide a value for it?
0
Hello Steve,
Please excuse me for the misunderstanding.
To achieve the desired result, you should first set the ClipboardCopyMode property of the control to "Cells,Header".
You can then handle the CopyingCellClipboardContent event in a similar fashion:
Please note, however, that prior to the 2017.3.1023 latest internal build and the R1 2018 official version of the UI for WPF controls, the CopyingCellClipboardContent will be thrown for the cells only so you will need to update your version of the suite if you wish to have the event thrown for the header and footer cells as well.
For your convenience, I'm attaching a small sample project demonstrating this implementation.
Please let me know if this works for you.
Regards,
Dilyan Traykov
Progress Telerik
Please excuse me for the misunderstanding.
To achieve the desired result, you should first set the ClipboardCopyMode property of the control to "Cells,Header".
You can then handle the CopyingCellClipboardContent event in a similar fashion:
private
void
ClubsGrid_CopyingCellClipboardContent(
object
sender, GridViewCellClipboardEventArgs e)
{
var control = e.Value
as
FrameworkElement;
if
(control !=
null
)
{
var textBlock = control.FindChildByType<TextBlock>();
e.Value = textBlock.Text;
}
}
Please note, however, that prior to the 2017.3.1023 latest internal build and the R1 2018 official version of the UI for WPF controls, the CopyingCellClipboardContent will be thrown for the cells only so you will need to update your version of the suite if you wish to have the event thrown for the header and footer cells as well.
For your convenience, I'm attaching a small sample project demonstrating this implementation.
Please let me know if this works for you.
Regards,
Dilyan Traykov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.