Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
194
Using xamDatagrid - Excel clipboard
posted

Hello,

I want to use my clipboard at xamDatagird.

I mean, I selected a row at MS Excel and then I wan to paste that in xamlDatagrid.

Is there a way? If it is possible, please let me know about that.

Thanks.

- JD

  • 69686
    Verified Answer
    posted

    Hello,

    This is really interesting question. XamDataGrid does not have this functionality but it can be easily achieved with some manual coding.

    Here is what I have come up for now. When you copy your row in Excel this is what follows :

    char[] separators = new char[3];
    separators[0] = ' ';
    separators[1] = '\t';
    separators[2] = '\n';
    separators[0] = '\r';

                if (Clipboard.GetDataObject().GetDataPresent(DataFormats.Text))
                {
                    string row = (Clipboard.GetDataObject().GetData(DataFormats.Text).ToString());
                    string[] cells =
    row.Split(separators,StringSplitOptions.RemoveEmptyEntries);
                }

    Then you take each item in cells ( which is each cell in MS Excell and give its value to the correspondent cell in the XamDataGrid.

    Hope this helps,

    Alex.