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

RadGridView copy/paste to/from excel questions

26 Answers 1069 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Dan Kinchen
Top achievements
Rank 1
Dan Kinchen asked on 19 Jul 2010, 09:40 PM
Hi,

I just noticed there is a feature listed for the RadGridView for being able to copy and paste to and from excel.  How exaclty does this work? 

Reference link:http://www.telerik.com/products/silverlight/gridview.aspx#copy/paste-in-radgrid-and-to/from-excel

First question: In the screenshot given the RadGridView appears to have an excel-like range of cells selected (as opposed to every column for every selected row).  How is that accomplished?  In my version I can only select an entire row.

Second question: I tried copying and pasting into excel and while it technically worked, the output I got was just the .ToString() output from the underlying ViewModel (using MVVM), not the value being displayed in the cell.  Is there a way to customize the paste behavior so it outputs the correct propery value of the underlying object?  I imagine I'll have the same question for import of taking an arbitrary shape of data from excel and getting it correctly mapped to the values in my object.

Third question:  If this works in excel, does it also work within the grid?  Namely in excel you can copy one cell, then highlight multiple other cells and paste and the value will be copied to each cell selected.  Can I do this within a given grid? (high priority wish-list item from my customer)

Final question: the version of the grid I am using is a few versions old now, which version do I need to support these features?

Thanks!

Dan

26 Answers, 1 is accepted

Sort by
0
Yavor Georgiev
Telerik team
answered on 20 Jul 2010, 09:04 AM
Hello Dan Kinchen,

 In order to make an arbitarily-shaped selection, there are a couple of properties you need to set on the RadGridView: SelectionUnit to Cell, and SelectionMode to Multiple or Extended.

Regarding your third question, you need to add the 'AllSelectedCells' flag to the ClipboardPasteMode property of the RadGridView (ex. radGridView1.ClipboardPasteMode = Cells | AllSelectedCells). When this flag is present, if you're pasting a single cell, but have multiple selected, the selected cells' values will be set to that of the pasted cell.

The Excel copy/paste functionality is present in our new 2010 Q2 version (2010.2.714).

I hope I was able to adequately answer your questions. Don't hesitate to come back to us whenever you have further inquiries.

Regards,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Dan Kinchen
Top achievements
Rank 1
answered on 20 Jul 2010, 01:34 PM
Thank you, one more quick question.  The project I'm working on is in Silverlight 3.  Is this new version (and functionality) compatable with SL3 or is it SL4 only?
0
Yavor Georgiev
Telerik team
answered on 20 Jul 2010, 01:40 PM
Hi Dan Kinchen,

 You can download the SL3 binaries for the 2010 Q2 version from your account's Download page.

Kind regards,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Dan Kinchen
Top achievements
Rank 1
answered on 20 Jul 2010, 02:08 PM
I downloaded the SL3 binaries and updated my project's references to the new binaries and I do not see the following properties available on the RadGridView:SelectionUnit,ClipboardPasteMode

I assume this is SL4 only functionality then?
0
Yavor Georgiev
Telerik team
answered on 20 Jul 2010, 03:19 PM
Hi Dan Kinchen,

 I apologize for misleading you. Indeed only the SL4 version boasts these new features.

Kind regards,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Dan Kinchen
Top achievements
Rank 1
answered on 26 Jul 2010, 04:45 PM
Ok, I have upgraded my project to SL4 to take advantage of these features.  I have a couple of questions regarding this now.

1) what is the easiest way to change the style of the selected cell (background specifically)?  I am using a custom cell style and it appears that for any column where I am using a non-default background color, the selected cell does not show so the user can't tell if they selected a cell.

2) While I can get exporting to excel working via setting up the DataMemberBinding for each column, importing from excel does not appear to work.  Is there some additional property I have to set?  I will admit, however, it's difficult to tell because I can't tell which cells I have selected due to issue #1.

Unrelated question:  I probably need to post this over on Silverlight.net but Intellisense seems to be broken for Silverlight in VS2010.  I ran into a similar issue with VS2008 when I had the SL4 runtime installed.  Is it because I still have the SL3 runtime installed?

0
Yavor Georgiev
Telerik team
answered on 26 Jul 2010, 04:59 PM
Hello Dan Kinchen,

 1) I will look into the cell selection style issue with our designers and let you know what I find. 
 2) Could you please send me your application so that I might debug it and see why pasting from Excel does not work?

Greetings,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Dan Kinchen
Top achievements
Rank 1
answered on 26 Jul 2010, 05:39 PM
It's very easy to reproduce.  I just modified a project I sent over to support for an issue with the SL4 version of the RadDataPager. 

Here is my XAML for the grid:
<telerik:RadGridView ItemsSource="{Binding MyItemsView}" SelectionMode="Extended" SelectionUnit="Cell" ClipboardPasteMode="AllSelectedCells"/>

The MyItemsView is a collection of these:

[DataContract]
public class MyDataItem
{
    [DataMember]
    public int ItemId { get; set; }
    [DataMember]
    public string ItemDesc { get; set; }
}

With the above grid, if I highlight a range of cells in the ItemDesc column, hit CTRL+C, open excel, hit CTRL+V, the data exports as expected.  If I reverse the process (modifying some data in excel so there is a change), nothing happens.  If I highlight a single cell in excel, hit CTRL+C, highlight a single cell in the grid and hit CTRL+V, nothing happens.  If I highlight a single cell in the grid, hit CTRL+C, highlight a different single cell in the same column (so the data types are the same), and hit CTRL + V nothing happens.

So to summarize:

Copy from Grid to Exel : works
Copy from Excel to Grid : fails
Copy from Grid to Grid : fails

Is there some additional property I need to set or some event I need to handle?
0
Yavor Georgiev
Telerik team
answered on 27 Jul 2010, 09:57 AM
Hi Dan Kinchen,

 Your project from the RadDataPager ticket works fine for me. Is there anything peculiar about your environment that might affect this? Also, you can try handling the Pasting and PastingCellClipboardContent events to see what happens.

Regards,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Dan Kinchen
Top achievements
Rank 1
answered on 27 Jul 2010, 08:33 PM
Sorry for the delay in replying.  First I had to re-write all of my cell styles because the old ones were disallowing the cell from properly highlighting (they were based on the old SL3 version of the GridView).

Anyway, now that I can actually see which cells are selected, the issue is when the ClipboardPasteMode is set to "AllSelectedCells".  If I leave it set to "Default" I can paste into a cell, but not multiple cells obviously.

Any clue as to why AllSelectedCells would not function?  I am using IE8 and Win XP Pro.

I added event handlers to the events you mentioned and they simply do not fire when using AllSelectedCells.  They do fire when set to Default.

EDIT:

Just to give you the specific use case I am testing,  I want to do the following all within the grid:

1) select a single cell
2) hit CTRL+C
3) select multiple cells
4) hit CTRL+V

Expected result: the value from #1 will show in all of the cells selected in #3
Actual result:
ClipboardPasteMode=Default - Value is only copied to the first selected cell
ClipbaardPasteMode=AllSelectedCells - nothing
0
Accepted
Yavor Georgiev
Telerik team
answered on 27 Jul 2010, 11:00 PM
Hi Dan Kinchen,

 ClipboardPasteMode (and ClipboardCopyMode, too) are Flags Enumeration properties - they allows you to set a combination of the enum values. Setting ClipboardPasteMode = GridViewClipboardPasteMode.AllSelectedCells does not include the GridViewClipboardPasteMode.Cells value, which the RadGridView looks for when checking whether pasting is enabled. You need to set the property like this:

radGridView1.ClipboardPasteMode = GridViewClipboardPasteMode.Cells | GridViewClipboardPasteMode.AllSelectedCells;

or, in XAML:
<telerik:RadGridView Name="radGridView1" SelectionMode="Extended" SelectionUnit="Cell" ClipboardPasteMode="Cells,AllSelectedCells"/>

All the best,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Dan Kinchen
Top achievements
Rank 1
answered on 28 Jul 2010, 07:20 PM
Thank you, that fixed it.

I will say it's not at all intuitive to set up the XAML like that.  If you try to manually type what you have in the XAML, VS2010 auto-completes it to just "AllSelectedCells" every time.  I had to copy the text from the forum post and paste it into VS2010 to get it to take it.
0
Dave
Top achievements
Rank 1
answered on 31 Aug 2010, 09:57 PM
Does this same functionality exist for ASP.NET?

Thanks,

Dave
0
Vlad
Telerik team
answered on 01 Sep 2010, 07:03 AM
Hi,

 As far as I know this is not available for our ASP.NET grid however it will be better to ask this in the relevant forum.

Greetings,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Dan
Top achievements
Rank 1
answered on 19 Jan 2011, 11:15 AM
Hi

We are evaluating the Telerik Grid and have a special Requirement (Silverlight 4) concerning copy paste (normally from excel).
Use case:
 
The user selects one cell in excel (or wherever) and then selects multiple cells in the telerik grid. Is it possible to paste the content of the one selected excel-cell in all seleted cells in the grid?

Excel cell   Silverlight Grid
a   a
  a
  a
  a
  a

Thanks and greetings


Dan
0
Veselin Vasilev
Telerik team
answered on 19 Jan 2011, 11:35 AM
Hello Dan,

Yes, this is possible - just set the following property of RadGridView:
ClipboardPasteMode="AllSelectedCells,Default"

In addition, to make multiple cells to be selected, you need to allow this by setting:
SelectionMode="Multiple" or SelectionMode="Extended" and
SelectionUnit="Cell"


Regards,
Veselin Vasilev
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Steve
Top achievements
Rank 1
answered on 14 May 2012, 07:57 PM
My users are asking for a Right Mouse Click popup menu that has Copy/Paste.   They say that not all users know the Ctrl-C,Ctrl-V by heart.

We have implemented this for TextBoxes, but we nee to get it to work for the Cut/Copy/Paste in RadGridViews. 

Does anyone have examples of this?

Thanks,
Steve
0
Maya
Telerik team
answered on 15 May 2012, 08:09 AM
Hi Steve,

You can define context menu (as illustrated in this demo) and work with the built-in commands Copy and Paste (take a look at our online documentation for a reference).
 

Regards,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Mike
Top achievements
Rank 1
answered on 13 Dec 2012, 09:35 AM
Hi, 

I have a problem when I use the Copy/past feature. Values are passed but I have to refresh the Gridview or doubleclick on each cell to see values.

This is my GridView parameters: 

<telerik:RadGridView ItemsSource="{Binding MyData}" BorderThickness="1,0,0,0" FrozenColumnCount="4" CanUserFreezeColumns="False" CanUserResizeRows="True" CanUserReorderColumns="False" CanUserResizeColumns="False" CanUserDeleteRows="False" CanUserInsertRows="False" AutoGenerateColumns="False" Background="White" RowIndicatorVisibility="Collapsed" BorderBrush="{StaticResource AccentBrush}" SelectionMode="Extended" SelectionUnit="Cell" ClipboardPasteMode="Cells,AllSelectedCells">

Thanks for help. 
0
Pavel Pavlov
Telerik team
answered on 13 Dec 2012, 09:37 AM
Hi Radouan,

You may need to implement the  INotifyPropertyChanged interface for your source objects in order to have the changes immediately reflected in the UI.

All the best,
Pavel Pavlov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Mike
Top achievements
Rank 1
answered on 13 Dec 2012, 09:44 AM
Hi Pavel,

Indeed, I used List rather than ObservableCollection. I replace it and it works well now. 
Thans for quick reply.

Regards.
0
Spencer
Top achievements
Rank 1
answered on 12 Nov 2018, 06:25 PM

Hi,

I am using Telerik Version 2018.2.613.40 and I do not see a GridViewClipboardPasteMode.Cells option or a GridViewClipboardPasteMode.AllSelectedCells option. Have these methods been replaced?

Thanks,

Spencer

0
Spencer
Top achievements
Rank 1
answered on 13 Nov 2018, 02:59 PM

Hi Telerik Team,

Any idea on this topic? I am using Telerik Version 2018.2.613.40 and C#. I am wondering if the option to set your Paste mode to allSelectedCells is still available. I am trying to do the same as the original request on this post by Dan Kitchen. Copy one cell and paste to multiple cells within the radgridview.

Thanks,

Spencer

0
Dinko | Tech Support Engineer
Telerik team
answered on 15 Nov 2018, 12:21 PM
Hi Spencer,

This functionality is available with the mentioned version in your post. Copying one cell you can paste it on all selected cells by specifying ClipboardCopyMode and ClipboardPasteMode properties.

Regards,
Dinko
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
Clara
Top achievements
Rank 1
answered on 28 Mar 2019, 02:29 PM

Hi,

I am trying to have the possibility to copy one value (of a cell) and pasting this value to the selected cells. I am able to do it but when I have to paste the value into more than 100 cells, it gets really slow.. about 20 seconds to paste the values.

The following code is the one I am using:

private void customMenuItem_Click(object sender, EventArgs e)
        {
            string comment = string.Empty;
            var selected_cells = radGridView1.SelectedCells;

            foreach (var item in selected_cells)
            {
                if (item.ColumnInfo.HeaderText == "ADDITIONAL COMMENTS")
                {
                    if (item.Value.ToString() != string.Empty)
                    {
                        comment = item.Value.ToString();
                    }
                    else
                    {
                        item.Value = comment;
                    }
                }
            }
            int rows = int.Parse(textBox2.Text.ToString());
        }

 

Please, if you could tell me how I can achieve this much faster it will be really useful. Right now I do not know how to do it.

In addition, I can only see the option "Enable or Disable" in the clipboardpastemode option.

Thanks in advance for your help!

0
Dinko | Tech Support Engineer
Telerik team
answered on 02 Apr 2019, 12:01 PM
Hi Clara,

In your post, you mentioned that the ClipboardPasteMode contains only Enable and Disable. The ClipboardPasteMode property of the RadGridView for Silverlight/WPF is an enumeration which contains the following values: None,Cells ,Default , OverwriteWithEmptyValues ,SkipFirstLine ,SkipLastLine ,AllSelectedCells ,SkipHiddenColumns , AllSelectedRows, InsertNewRows.

Can you confirm that you are using RadGridView for Silverlight and the version of our assemblies which you are using referencing?

Regards,
Dinko
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
Dan Kinchen
Top achievements
Rank 1
Answers by
Yavor Georgiev
Telerik team
Dan Kinchen
Top achievements
Rank 1
Dave
Top achievements
Rank 1
Vlad
Telerik team
Dan
Top achievements
Rank 1
Veselin Vasilev
Telerik team
Steve
Top achievements
Rank 1
Maya
Telerik team
Mike
Top achievements
Rank 1
Pavel Pavlov
Telerik team
Spencer
Top achievements
Rank 1
Dinko | Tech Support Engineer
Telerik team
Clara
Top achievements
Rank 1
Share this question
or