Here is my code
Public Shared Sub Export(ByVal fileName As String, ByVal gv As GridView)
HttpContext.Current.Response.Clear()
HttpContext.Current.Response.AddHeader("content-disposition", String.format("attachment; filename={0}", fileName))
HttpContext.Current.Response.ContentType = "application/ms-excel"
Using sw As New StringWriter()
Using htw As New HtmlTextWriter(sw)
' Create a form to contain the grid
Dim table As New Table()
' add the header row to the table
If gv.HeaderRow IsNot Nothing Then
TRUtilities.PrepareControlForExport(gv.HeaderRow)
table.Rows.Add(gv.HeaderRow)
End If
' add each of the data rows to the table
For Each row As GridViewRow In gv.Rows
TRUtilities.PrepareControlForExport(row)
table.Rows.Add(row)
Next
' add the footer row to the table
If gv.FooterRow IsNot Nothing Then
TRUtilities.PrepareControlForExport(gv.FooterRow)
table.Rows.Add(gv.FooterRow)
End If
' render the table into the htmlwriter
table.RenderControl(htw)
' render the htmlwriter into the response
HttpContext.Current.Response.Write(sw.ToString())
HttpContext.Current.Response.[End]()
End Using
End Using
End Sub
The above code works fine with Http and Https for Firefox. It doen't work in IE for Https.