I have this code to export DataGrid to Excel:
Response.Clear()
Response.Buffer = True
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""
Me.EnableViewState = False
Dim datiExcel As String
Dim SW As System.IO.StringWriter = New System.IO.StringWriter()
Dim HTW As System.Web.UI.HtmlTextWriter = New System.Web.UI.HtmlTextWriter(SW)
DataGrid1.RenderControl(HTW)
Response.Write(SW.ToString())
Response.End()
This code works well but how is possible to export in a new window different from the page of datagrid?
Thanks