I do not have the time to really test out, but just wondering the regular code behind web function, used it as either web service or page function, can deliver the data directly to excel.
Something like the following:
string attachment = "attachment; filename=" + tablename + ".xls";
Response.ClearHeaders();
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/vnd.ms-excel";
StringWriter sw = new StringWriter();
DataView dv = dt.DefaultView;
string filter;
if (userid.Text == "")
filter = "userid <> ''";
else
filter = "userid = '" + userid.Text + "'";
DataRow[ rows =dt.Select(filter);
// Response.Write("<html>");
Response.Write("<HTML><head></head><body><table>");
Response.Write("<tr>");
for (int j = 0; j < dt.Columns.Count; j++)
Response.Write("<td>" + dt.Columns[j].ColumnName + "</td>");
Response.Write("</tr>");
for (int i = 0; i < rows.Length; i++)
{
Response.Write("<tr>");
for (int j = 0; j < dt.Columns.Count; j++)
Response.Write("<td>" + rows
[j].ToString() + "</td>");
}
Response.Write("</tr>");
Response.Write("</table>" );
Response.Write("</body></html>");
//HtmlTextWriter htw = new HtmlTextWriter(sw);
//gvwSurvey.RenderControl(htw);
Response.End();