Skip to content

Instantly share code, notes, and snippets.

@coridrew
Last active December 11, 2015 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coridrew/4640645 to your computer and use it in GitHub Desktop.
Save coridrew/4640645 to your computer and use it in GitHub Desktop.
public void ProcessRequest(HttpContext context)
{
context.Response.Clear();
context.Response.ContentType = "application/force-download";
context.Response.AddHeader("content-disposition", "attachment; filename=Current-OptIns_" + DateTime.UtcNow.ToString("yyyyMMddHHmm") + "utc.xls");
List<ExpandoObject> optInList = DbServices.GetCurrentOptIns(optInList);
DataTable dt = optInList.ToDataTable();
GridView gv = new GridView();
gv.DataSource = dt;
gv.DataBind();
var sw = new StringWriter();
var writer = new HtmlTextWriter(sw);
gv.RenderControl(writer);
context.Response.Write(sw.ToString());
context.Response.End();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment