Hi, I am writting a program to let user generate excel file from the datagrid in web page. Below is the codes:
Private Sub ConvertToExcel(ByVal Data As ProductionScheduleData) Dim stringwrite As New System.IO.StringWriter Dim htmlWrite As New System.Web.UI.HtmlTextWriter(stringwrite) GridExcel.RenderControl(htmlWrite) Response.Clear() Response.ClearContent() Response.ClearHeaders() Response.BufferOutput = True Response.AddHeader("Content-Disposition", "attachment;filename=" + "ProductionSchedule" + ".xls") Response.Charset = "" Response.ContentType = "application/vnd.ms-excel" Response.Write(stringwrite.ToString()) Response.Flush() Response.Close() Response.End() End Sub
The excel file was successfully generated. My problem is, after the file generated, the web page seem like still processing something. I can't do the next action, unless I reentry that page with new action. Did I miss something in my codes? It seem like the response does not fully close, or something else. I said that because the problem occured when it reach the codes line "Response.AddHeader".
Anyone can helps? Thanks in advanced.