I have an asp.net application where I would like to export the contents of the datagrid to excel.
I have seen a few examples where the datagrid is exported, but in my case I want a header row on the first line of the excel workseet with the filters that were used
StartDate 10/01/2011 - EndDate 10/31/2011
Grid data follows
Any code sample would be great.
I saw this example
private void LinkButton1_Click(object sender, System.EventArgs e)
Response.Charset = "";
Response.ContentType = "application/vnd.ms-excel";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
System.Web.UI.WebControls.DataGrid myGrid = (System.Web.UI.WebControls.DataGrid)PlaceHolder1.FindControl("DataGrid1");