Results 1 to 3 of 3

Thread: Need help with Clipboard and copy to-from Excel

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    May 2002
    Posts
    1,602

    Need help with Clipboard and copy to-from Excel

    Hi!

    I am trying to figure out how to send a List<Of Person> into the clipboard so I can paste the properties as text in excel.

    Person is an object that has some basic properties such as FirstName, LastName, Age etc And when paste in excel I want the list to be represented as a number of rows.

    Likewise, when I select some text data in excel, and then trigger a paste command in my windows app, I want the selected data to update the existing list of persons.

    Basically there is a grid control that has a datasource of List<Of Person> and I want to update this list when "pasting" text data. The paste will be stupid as in there is no check as to data types, simply paste and replace text. Also if I get out of bounds in the list I will add new rows in my list. Finally I do a refresh of the data source and the pasted info is displayed.

    I have tried to google for this, but can only find the very basic type of examples when dealing with clipboard. Not how to "serialize" text to objects.

    What I need are two methods, one that take input of clipboard and existing List and output a list where clipboard and existing lists have been "merged". And another function that creates clipboard info from an existing list called "Selectedrows". For the sake of simplicity it is only possible in this first version to deal only with rows...

    Anyone has ideas on how to handle conversion from List<Of Person> to Clipboard and back again? Maybe write a small example?

    Thanks!
    Henrik

  2. #2
    PowerPoster
    Join Date
    Oct 2008
    Location
    Midwest Region, United States
    Posts
    3,574

    Re: Need help with Clipboard and copy to-from Excel

    What if you wrote your "list" to the clipboard as a concatenated string, delimited by a specific character, then "parsed" it when you get it into Excel?

  3. #3
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Need help with Clipboard and copy to-from Excel

    The chief problems with this are ...

    ... using the clipboard; there's just no obvious reason to so.

    ... using a list as a datasource. Only datatable provides two way binding , ie. updates automatically when values are added to or amended in the DGV
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width