Silverlight Export Datagrid to Excel (without roundtrip)

Posted by kirkktx on Stack Overflow See other posts from Stack Overflow or by kirkktx
Published on 2009-06-18T21:32:46Z Indexed on 2010/05/24 12:41 UTC
Read the original article Hit count: 148

Filed under:
|
|

I've got a silverlight 2 app with a Datagrid and a button for exporting it to Excel by making a trip back to the server.

I can create an HTML string representing the datagrid. I'd like to attach this string to an html element, setting MIME type=application/vnd.ms-excel and have a prompt show up asking if I'd like to open or save the xls file.

After all if ASP can do this ...

<% The main feature of this technique is that %>  
<% you have to change Content type to ms-excel.%>

Response.ContentType = "application/vnd.ms-excel"
<TABLE>  
<TR><TD>2</TD></TR>  
<TR><TD>3</TD></TR>  
<TR><TD>=SUM(A1:A2)</TD></TR>  
</TABLE>

... it seems like I should be able to do something similar from within Silverlight, pushing it onto the HTML DOM.

Any suggestions greatly appreciated!

© Stack Overflow or respective owner

Related posts about Silverlight

Related posts about excel