Steve,
Thank you for the prompt reply. Response.Clear does not help though.
Listing out the full piece of code for better clarity.
Dim strFileName As String
Dim strHTML As String
Dim strAddInfo As String
HttpContext.Current.Response.Clear()
HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"
strReportName = "EXPORT REPORT"
strFileName = "ABC.xls"
strAddInfo = "Additional Info"
strHTML = GetGHTML() 'This is responsible for getting report in HTML format
HttpContext.Current.Response.AddHeader("content-disposition",
"attachment;filename=" & strFileName)
HttpContext.Current.Response.Charset = ""
HttpContext.Current.Response.Write("<h4>" & strReportName & "</h4>")
HttpContext.Current.Response.Write(strAddInfo)
HttpContext.Current.Response.Write("<br><br>")
HttpContext.Current.Response.Write(strHTML)
HttpContext.Current.Response.End()
Hemant
"Steve C. Orr [MVP, MCSD]" wrote:
> Try putting a Response.Clear() line at the beggining of your code block.
>
> --
> I hope this helps,
> Steve C. Orr, MCSD, MVP
> http://SteveOrr.net
>
>
> "Hemant Sipahimalani" <Hemant > wrote
> in message news:C0FC2030-600D-4D1D-88FB-...
> > The following piece of code is being used to export HTML to excel.
> >
> > HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"
> > HttpContext.Current.Response.AddHeader("content-disposition",
> > "attachment;filename=ABC.xls")
> > HttpContext.Current.Response.Write(strHTML)
> > HttpContext.Current.Response.End()
> >
> > However when the user tries to save it the Default File Type is Web
> > Page(*.htm; *.html)
> > How do we change the Default File Type to Excel
>
>
>