Export data to Excel problem
-
Following code does not handle columns that start with +. for example, '+923339933886' is not rendered well(some kind of charmap characters shown).
HtmlForm form = new HtmlForm(); string attachment = "attachment; filename=Employee.xls"; Response.ClearContent(); Response.AddHeader("content-disposition", attachment); Response.ContentType = "application/ms-excel"; StringWriter stw = new StringWriter(); HtmlTextWriter htextw = new HtmlTextWriter(stw); form.Controls.Add(gvEmployee); this.Controls.Add(form); form.RenderControl(htextw); Response.Write(stw.ToString()); Response.End();
Please let me know what is the changes required in this code.
-
Following code does not handle columns that start with +. for example, '+923339933886' is not rendered well(some kind of charmap characters shown).
HtmlForm form = new HtmlForm(); string attachment = "attachment; filename=Employee.xls"; Response.ClearContent(); Response.AddHeader("content-disposition", attachment); Response.ContentType = "application/ms-excel"; StringWriter stw = new StringWriter(); HtmlTextWriter htextw = new HtmlTextWriter(stw); form.Controls.Add(gvEmployee); this.Controls.Add(form); form.RenderControl(htextw); Response.Write(stw.ToString()); Response.End();
Please let me know what is the changes required in this code.
Are you sure you will get a better response this time then That[^]?
Regards, Hiren.
My Recent Article: - Way to know which control have raised a postback
My Recent Tip/Trick: - Remove HTML Tag, get plain Text -
Following code does not handle columns that start with +. for example, '+923339933886' is not rendered well(some kind of charmap characters shown).
HtmlForm form = new HtmlForm(); string attachment = "attachment; filename=Employee.xls"; Response.ClearContent(); Response.AddHeader("content-disposition", attachment); Response.ContentType = "application/ms-excel"; StringWriter stw = new StringWriter(); HtmlTextWriter htextw = new HtmlTextWriter(stw); form.Controls.Add(gvEmployee); this.Controls.Add(form); form.RenderControl(htextw); Response.Write(stw.ToString()); Response.End();
Please let me know what is the changes required in this code.