Hi There,
I had this post before,but I have some problems when I add a header for specific charcter set,and also add some additional data,
here is my code;
Response.Clear();
Response.ClearHeaders();
Response.ClearContent();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment;filename=aname.xls");
string header = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n<title></title>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1254\" />\n<style>\n</style>\n</head>\n<body>\n";
Response.ContentEncoding = System.Text.Encoding.GetEncoding("windows-1254");
Response.Charset = "windows-1254"; //ISO-8859-9 windows-1254
Response.ContentType = "application/vnd.ms-excel";
System.IO.StringWriter sw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(sw);
gvMaster.AllowPaging = false;
gvMaster.RenderControl(hw);
//write the output
Response.Output.Write(header.ToString());
Response.Output.Write("Some title\n");
Response.Output.Write("\n");
//to write current date and time
System.DateTime tDate1 = System.DateTime.Now;
Response.Output.Write(tDate1);
Response.Output.Write("\n");
Response.Output.Write(sw.ToString());
Response.Flush();
Response.End();
The problem is when I add header next Line is not working and the Title and system time are all in one row,
My question is how can I write the gridview to specific row in output excel or how can I add some line on top of gridview and also how can I add some style to title?
Thanks in advance