Silverlight Export Datagrid to Excel (without roundtrip)
- by kirkktx
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!