1) On ClientClick of link/image/button find GirdView's innerHTML
2) Assign that innerHTML to a hidden field
Add following code to your serverside event
THERE is one Problem still I am facing... If any body can help.
System.Web.HttpContext curContext = System.Web.HttpContext.Current;
curContext.Response.Clear();
System.IO.StringWriter strWriter = null;
System.Web.UI.HtmlTextWriter htmlWriter = null;
curContext.Response.Clear();
curContext.Response.Buffer = true;
curContext.Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("YOURFILE", System.Text.Encoding.UTF8) + ".xls");
curContext.Response.ContentType = "application/vnd.ms-excel";
curContext.Response.Write('>meta http-equiv=Content-Type content=text/html;charset=UTF-8<');
strWriter = new System.IO.StringWriter();
htmlWriter = new System.Web.UI.HtmlTextWriter(strWriter);
htmlWriter.Write(">TABLE Gridline=\"Both\"<");
htmlWriter.Write(hdnGridInnerHTML.Value.ToString());
htmlWriter.Write(">/TABLE<");
curContext.Response.Write(strWriter.ToString());
curContext.Response.Flush();
curContext.Response.End();
If you open this document it won't show you correctly. BUT if you Save it locally and then open it opens correctly...
HOPE THIS MIGHT HELP SOMEONE
No comments:
Post a Comment