I ran across this 2x in about 15 minutes, and it seemed like fun to try. You can "convert" your data to a downloadable spreadsheet in ASP.NET by 1) outputting it as an HTML table and 2) setting the page's ContentType to "application/vnd.ms-excel". (References/credit here and here.)
If you have Excel installed, try it by clicking here, where you get the 10 most recent blog entries (abbreviated) in a spreadsheet.
The code:<%@ Page Language="VB" Debug="true" EnableViewState="False" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server">
Sub Page_Load()
Dim ds As Dataset = GetBlog()
Dim dr As Datarow
Dim tableString As New StringBuilder
tableString.Append("<table border=1>")
tableString.Append("<thead><th>Title</th><th>EntryDate</th>" & _
"<th>Text</th></thead>")
For Each dr in ds.Tables(0).Rows
tableString.Append("<tr><td>" & dr("title") & _
"</td><td>" & dr("EntryDateTime") & "</td><td>" & _
Server.HtmlEncode(dr("ShortDescription")) & "</td></tr>")
Next
tableString.Append("</table>")
Literal1.Text = tableString.ToString()
Response.ContentType = "application/vnd.ms-excel"
End Sub
Function GetBlog() As System.Data.DataSet
Dim connectionString As String = _
ConfigurationSettings.AppSettings("connectionString")
Dim dbConnection As New SqlConnection(connectionString)
Dim queryString As String = "SELECT top 10 Title, EntryDateTime, " & _
" Substring(Description, 0, 25) As ShortDescription FROM [blog] " & _
" ORDER BY EntryDateTime DESC"
Dim dbCommand As New SqlCommand(queryString, dbConnection)
Dim dataAdapter As New SqlDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim dataSet As New System.Data.DataSet
dataAdapter.Fill(dataSet)
Return dataSet
End Function
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<asp:Literal id="Literal1" runat="server"></asp:Literal>
</form>
</body>
</html>