Ankit Agarwal

Ankit Agarwal

  • NA
  • 379
  • 254.3k

Error Export to excel download.

Sep 26 2015 2:28 AM
Hello,
 
I am using this code but its getting error:- system.io.streamwriter' does not contain a constructor that takes 0 arguments. 
public void ExportDetails() {  SqlConnClass connClass = new SqlConnClass();         DataTable dt = connClass.GetQrCodeDetails();         GridView gv = new GridView();         gv.AutoGenerateColumns = false;           BoundField ID = new BoundField();         ID.HeaderText = "ID";         ID.DataField = "ID";         gv.Columns.Add(ID);           BoundField QRIMAGE = new BoundField();         IMAGE.HeaderText = "IMAGE";         IMAGE.DataField = "IMAGE";         gv.Columns.Add(IMAGE);           StreamWriter sw = new StreamWriter(); //Error is showing in this line.         HtmlTextWriter htw = new HtmlTextWriter(sw);         gv.RenderControl(htw);         Response.Write(htw); ExportTableData(sw.ToString()); }   public void ExportTableData(string data)     {         string attach = "attachment;filename=CodeDetails.xls";         Response.ClearContent();         Response.AddHeader("content-disposition", attach);         Response.ContentType = "application/ms-excel";           Response.Write(data);         Response.End();     }

please help me.
How to resolve this error.

Thanks in Advance.

Ankit Agarwal
Software Engineer
 

Answers (2)