I am trying to export a report into excel in vb.net.
everything works fine in Chrome and FF, but when i do it in IE, the active directory login pop up keeps coming up.
if i cancel it (like 4-5 times) the files saves just fine… why is it popping up> is there a way around it?
please see my code below:
Protected Sub lnkExport_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkExport.Click
Dim ds As DataSet = cSource.FindSources(Session("uid"), True, txtID.Text )
Dim response As HttpResponse = HttpContext.Current.Response
Dim filename As String = "AASD"
' first let's clean up the response.object
response.Clear()
response.Charset = ""
' set the response mime type for excel
response.ContentType = "application/vnd.ms-excel"
response.AddHeader("Content-Disposition", "attachment;filename=""" & filename & """")
' create a string writer
Using sw As New StringWriter()
Using htw As New HtmlTextWriter(sw)
' instantiate a datagrid
Dim dg As New DataGrid()
dg.DataSource = ds.Tables(0)
dg.DataBind()
dg.RenderControl(htw)
response.Write(sw.ToString())
response.[End]()
End Using
End Using
End Sub
it got fixed by writing out the data to excel, cell by cell in a loop.