Hari B

Hari B

  • NA
  • 139
  • 68.3k

multiple Excel files download

Sep 3 2015 4:08 AM
Hello All
 
Here I need to download multiple Excel sheets i use for loop. after one iterate loop I got am Exception like below
 
 Server cannot append header after HTTP headers have been sent.
 
 try
    for(some condition)
   { 
        //some code grid view// 
 
         Response.ClearContent();
         Response.Buffer = true;
         long lnUserID = clsLists.getCurrentUserId(); 
         Response.AddHeader("content-disposition", "attachment; filename=Release-" + ReleaseEMCTSDB.users.SingleOrDefault(u => u.UserId ==
         l nUserID).UserName + "-" + DateTime.Now.ToString() + ".xls");
         Response.AppendHeader("Name", "Value");
         Response.ContentType = "application/ms-excel";
         Response.Charset = "";
         StringWriter sw = new StringWriter();
         HtmlTextWriter htw = new HtmlTextWriter(sw);
         string readergridview = sw.ToString();
         gv.RenderControl(htw);
         Response.Output.Write(sw.ToString());
         Resp onse.Flush();
         Response.End();
     } 
try
{
 Exception
}
 
Please help me it is possible to iterate loop 
 

Answers (2)