Created
May 8, 2017 10:24
-
-
Save shammelburg/b3d3c08ca9c11978de1fdc747eb11bf6 to your computer and use it in GitHub Desktop.
Create an excel file
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
string fileName = string.Empty; | |
var grid = new System.Web.UI.WebControls.GridView(); | |
grid.DataSource = _db.spArtworkContentReport_ContentOnly_DI_Buyer(true, false).ToList(); | |
fileName = "DataReport"; | |
grid.DataBind(); | |
Response.ClearContent(); | |
Response.AddHeader("content-disposition", "attachment; filename=" + fileName + "_" + DateTime.Now.ToString() + ".xls"); | |
Response.ContentType = "application/excel"; | |
StringWriter sw = new StringWriter(); | |
HtmlTextWriter htw = new HtmlTextWriter(sw); | |
grid.RenderControl(htw); | |
Response.Write(sw.ToString()); | |
Response.End(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment