1
Answer

Saving HTML into excel without showing save/open dialog.

Photo of Sri Kanth

Sri Kanth

8y
608
1
Try
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()
Catch ex As Exception
Throw ex
End Try
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. 

Answers (1)