Copy and paste to exel

2 posts, 0 answers
  1. Stefania
    Stefania avatar
    154 posts
    Member since:
    May 2013

    Posted 11 Mar 2015 Link to this post

    When I try to copy a lot of data from my grid to the excel sheet, some rows are missing.

    I found this solution on your forum

    private void gridview_Copying(object sender, RadRoutedEventArgs e)
    var obj = Clipboard.GetDataObject();
               var data = obj.GetData(DataFormats.Text);
               Clipboard.SetData(DataFormats.Text, data);

    All data now are copied to excel but if into a cell there is a newline char, excel will create a new row
    How can I fix it?

    Another question..
    I read that when I copy from grid on the clipboard all data are saved as html, csv and txt
    My grid has around 500 000 cells, and the coping operation is not performed at all.
    I think the problem is the html, and I need only the data without any kind of formatting.
    So is it possible to saved only the txt on the clipboard?


  2. Maya
    Maya avatar
    4062 posts

    Posted 12 Mar 2015 Link to this post

    Hello Stefania,

    It is a bit strange that not all of the items are copied. Do you work with VirtualQuerableCollectionView so that not all of the objects are loaded ?
    Considering the code, my suggestion would be to implement the logic in Copied event instead. Once you get the data from the clipboard, you can manipulate it and remove all unwanted characters. 
    As for your last question, I am not entirely sure what is going on. Could you try Microsoft DataGrid - are the items copied ? Are the Copying/Copied events of RadGridView thrown ?  


    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top