Last active
December 11, 2015 18:19
-
-
Save coridrew/4640645 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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