I’m looking at developing a Silverlight application that displays a lot of information in a DataGrid.
I want to somehow give the users the ability to copy this into Excel via the clipboard.
Is this even possible in Silverlight 3?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
OK, I’ve figured out how to do it, but it’s not exactly elegant.
First of all, I lifted the CopyClipboard function from Jeff Wilcox’s Blog.
Now I’ve written code to generate an HTML table from the grid, and put that into the clipboard.
It’s especially bad because it’s calling
rather than
Because the second one throws a “System.InvalidOperation” exception. That means if you copy it into Word instead of Excel it isn’t a table, it’s a block of HTML.
But, yes, copying the datagrid contents to Excel via the clipboard is possible. Sort of.