Dim attachment As String = "attachment; filename=DataReport.xls"
Response.ClearContent()
Response.AddHeader("content-disposition", attachment)
Response.ContentType = "application/ms-excel"
Dim sw As StringWriter = New StringWriter()
Dim str As String = sb.ToString
Response.Write(str.ToString())
Response.Flush()
Response.End()
In this str variable has html mark. Using this code i am able to generate excel file but it is showing open/save dialog. User should not see this dialog and the generated excel should be saved to a given location.