This is a migrated thread and some comments may be shown as answers.

Export template to excel

3 Answers 95 Views
GridView
This is a migrated thread and some comments may be shown as answers.
alejandro
Top achievements
Rank 1
alejandro asked on 12 Jun 2019, 02:51 PM
Hello,

I have a gridview.
In one of its columns I have a template with a collection.

When trying to export it to excel this column export only "(Collection)".

How can I export it?

Thank you.

 

<telerik:GridViewDataColumn Header="NÂș Casilla" DataMemberBinding="{Binding Casilla}" IsReadOnly="True" /><telerik:GridViewDataColumn Header="Casilla" DataMemberBinding="{Binding Converter={StaticResource EstructurasConverter}, ConverterParameter=ValoresCasillas }" IsReadOnly="True" Width="auto">
                        <telerik:GridViewDataColumn.CellTemplate>
                            <DataTemplate>
                                    <ListView Background="Transparent" BorderBrush="Transparent" BorderThickness="0"  ItemsSource="{Binding Converter={StaticResource EstructurasConverter}, ConverterParameter=ValoresCasillas }">
                                    <ListView.ItemTemplate>
                                        <DataTemplate>
                                            <Border  BorderThickness="0,0,0,1" Padding="0,0,0,8" AutomationProperties.IsRowHeader="True" BorderBrush="#D0D0D0">
                                                <StackPanel Background="Transparent"   Orientation="Horizontal">
                                                    <StackPanel Orientation="Vertical" Width="265" Background="Transparent" >
                                                        <TextBox BorderThickness="0"  BorderBrush="Transparent" Background="Transparent"  IsReadOnly="True"  Text="{Binding TextoFila, Converter={StaticResource MaxCharactersEpigrafeConverter}}"   Width="auto" />
                                                        <TextBox BorderThickness="0"  BorderBrush="Transparent" Background="Transparent" IsReadOnly="True"  Text="{Binding TextoColumna, Converter={StaticResource MaxCharactersEpigrafeConverter}}"    Width="auto" />
                                                    </StackPanel>
                                                    <TextBox BorderThickness="0" BorderBrush="Transparent" Background="Transparent" IsReadOnly="True"  Text="{Binding FAlta, Converter={StaticResource CofeToNormalConverter}}"  Width="auto" />
                                                    <TextBox BorderThickness="0"  TextWrapping="Wrap"  BorderBrush="Transparent" Background="Transparent" IsReadOnly="True"   Text="-"  Width="auto" />
                                                    <TextBox BorderThickness="0" BorderBrush="Transparent" Background="Transparent" IsReadOnly="True"   Text="{Binding FBaja,Converter={StaticResource CofeToNormalConverter}}"  Width="auto" />
                                                </StackPanel>
                                            </Border>
                                        </DataTemplate>
                                    </ListView.ItemTemplate>
                                </ListView>
                            </DataTemplate>
                        </telerik:GridViewDataColumn.CellTemplate>

 

 

 

 

 

3 Answers, 1 is accepted

Sort by
0
Vladimir Stoyanov
Telerik team
answered on 13 Jun 2019, 11:53 AM
Hello Alejandro,

Thank you for the provided picture and code snippet. 

The observed behavior is actually the expected one. Please, allow me to elaborate:

The CellTemplate property of the column allows you to place anything that you want inside the cell when it is in view mode. However, in this way the RadGridView does not know how to export the custom cell content. 

In order to achieve what you are going for, you can handle the ElementExporting or ElementExportingToDocument event(depending on which export mechanism you are using) and set the value for the cells in that column. You can use an approach similar to the one demonstrated in the following article: Export Custom Header.

I hope you find this helpful.

Regards,
Vladimir Stoyanov
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
alejandro
Top achievements
Rank 1
answered on 14 Jun 2019, 06:32 AM

thank you very much for your reply.

I am doing testing and I have encountered the following problem.

When I export two lines to an excel does not recognize them.

How can I export two lines in the same cell to excel?

 

If e.Element = ExportElement.Cell Then
 
         If Not IsNumeric(e.Value) Then
             e.Value = "Line 1" & Environment.NewLine & "Line 2"
 
         End If
 
     End If

 

 

0
Vladimir Stoyanov
Telerik team
answered on 18 Jun 2019, 12:24 PM
Hello Alejandro,

Thank you for the attached pictures.

It seems that this can be controlled by using the Wrap text in a cell excel functionality.  Can you use this feature over the cells that have a new line inserted in them and see if that achieves the desired result? 

I hope you find this helpful.

Regards,
Vladimir Stoyanov
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
GridView
Asked by
alejandro
Top achievements
Rank 1
Answers by
Vladimir Stoyanov
Telerik team
alejandro
Top achievements
Rank 1
Share this question
or