Recently, I meet a requirement about exporting data to excel file from ASP.NET. The requirement is very simple. There is one button on a page, when you click the button, there would be a dialog asking you if you want to open or save the Excel file. If your data is simple and you just want a CSV or XLS.The implementation is simple.And from this example. we know how to export other types’ file like below.this.Page.Response.ClearContent();
this.Page.Response.ContentType = "application/vnd.ms-excel";
this.Page.Response.AddHeader("content-disposition", "attachment; filename=Contact.xls");
this.Page.Response.Write(your data);
this.Page.Response.End();
No comments:
Post a Comment