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

Line breaks not reserved when copying from gridview to excel

5 Answers 257 Views
GridView
This is a migrated thread and some comments may be shown as answers.
yijie
Top achievements
Rank 1
yijie asked on 21 Jan 2013, 11:34 AM
Hi,

When I tried to copy mulitple rows and cells from RadGridView to MS Excel I found out that the line breaks in cell seemed removed. All statements in the cell present in one single line after pasting into MS Excel cell. Is there a solution to reserve the line breaks in the cell after copy/paste ?

BTW Last time I got confirmation that the copy of RadGridView will only contains plain text and the font size and font family will not be copied at all. Is that supported in latest version ?

Thanks,
Alex

5 Answers, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 24 Jan 2013, 11:28 AM
Hi Alex,

I'm afraid you can not have exact pasted copy of RadGridView, because it will store in the clipboard raw data only.

Regards,
Yoan
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
yijie
Top achievements
Rank 1
answered on 24 Jan 2013, 11:33 AM
Hi Yoan,

Thanks for you reply. So it means if I have to preserve the link breaks ( \r\n ) I need to consturct the raw data myself or convert the text data in cells from RadGridView into RTF or HTML formart right ?

Regards,
Alex 
0
Dimitrina
Telerik team
answered on 29 Jan 2013, 09:57 AM
Hi Alex,

I have a test project and a column with CellEditTemplate defined like so:

<telerik:GridViewDataColumn DataMemberBinding="{Binding Name}">
    <telerik:GridViewDataColumn.CellEditTemplate>
        <DataTemplate>
            <TextBox Text="{Binding Name}" AcceptsReturn="True"/>
        </DataTemplate>
    </telerik:GridViewDataColumn.CellEditTemplate>
</telerik:GridViewDataColumn>

Then I edit the name, so that there are some line breaks: \r\n. Then I select the content and copy it (Ctrl + C). Then I paste it (Ctrl + P) into another cell from the same column and into an Excel file. In both the cases the line breaks were preserved (if the width of the cell in Excel is at least the one we need for the pasted content).

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
yijie
Top achievements
Rank 1
answered on 30 Jan 2013, 02:18 AM
Hi Didie,

Thank you very much for your workaround solution. However as we noticed if applying celledittemplate to RadGridView there will be a serious performace issue due to the real data is quite large. Anyway I will give it a try and wish it could be in use.

Thanks
Alex
0
Dimitrina
Telerik team
answered on 30 Jan 2013, 07:53 AM
Hi Alex,

I am glad to hear that, hopefully you could indeed use it. 

Kind regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
yijie
Top achievements
Rank 1
Answers by
Yoan
Telerik team
yijie
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or