Sri Kanth

Sri Kanth

  • NA
  • 7
  • 2.6k

Saving HTML into excel without showing save/open dialog.

Aug 12 2016 5:18 AM
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)