I am adding the grid table to the excel and adding a header to the excel.
string subject = lbl_Subj.Text;
Response.Clear();
Response.Buffer = true;
Response.ClearHeaders();
Response.AddHeader("Cache-Control", "no-store, no-cache");
Response.AddHeader("content-disposition", "attachment;filename=" + subject + "-Status");
Response.Charset = "";
this.EnableViewState = false;
Response.ContentType = "application/vnd.ms-excel";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
Grid_UserTable.RenderControl(htmlWrite);
rptList.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
How can I add some text to the excel, I want to add some string like
string add="this is the text I want to add to the excel";
As long as you are on office 2007/2010, you can use Office Open XML - http://msdn.microsoft.com/en-us/office/ee358824
Regards, Nitin Rastogi