Apurva Singh

Apurva Singh

  • NA
  • 268
  • 57.4k

export to excel

Jul 13 2018 5:34 AM
I have a gried view data.
 
on export to excel click  it return only <div> </div>.
 
 
Here is my code.
 
 
Response.Clear();
Response.Buffer = true;
Response.ClearContent();
Response.ClearHeaders();
Response.Charset = "";
string FileName = "StockinhandDetails" + DateTime.Now + ".xls";
StringWriter strwritter = new StringWriter();
HtmlTextWriter htmltextwrtter = new HtmlTextWriter(strwritter); here return data <div> </div>
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/ms-excel";
Response.AddHeader("Content-Disposition", "attachment;filename=" + FileName);
smallbanner1.GridLines = GridLines.Both;
smallbanner1.HeaderStyle.Font.Bold = true;
smallbanner1.RenderControl(htmltextwrtter);
Response.Write(strwritter.ToString());
Response.End();
Please help.
 
 

Answers (2)