R
RSH
Hi,
Im using the code below to render a datagrid as an Excel file. It seems to
work fine when the user clicks on the Save button. But when they click on
the open button, it renders correctly but when the user attempts to save the
document from the browser...it saves it as an HTML file. Is there any way
to disable the Open button and force the user to save the file? Or some
other trick to make sure the file saves as a type xls?
Response.Clear()
Response.Buffer = True
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""
Response.AddHeader("Content-Disposition",
"attachment;filename=ClientAlertExport" & Now() & ".xls")
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()
Thanks,
Ron
Im using the code below to render a datagrid as an Excel file. It seems to
work fine when the user clicks on the Save button. But when they click on
the open button, it renders correctly but when the user attempts to save the
document from the browser...it saves it as an HTML file. Is there any way
to disable the Open button and force the user to save the file? Or some
other trick to make sure the file saves as a type xls?
Response.Clear()
Response.Buffer = True
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""
Response.AddHeader("Content-Disposition",
"attachment;filename=ClientAlertExport" & Now() & ".xls")
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()
Thanks,
Ron