C# .NET - save file type as xls by default - Asked By abinav shankar on 19-Feb-13 03:07 AM

Hi
 
I have used the following code to convert the html table to excel and it works fine but the default save file type is Web Page(*.htm; *.html) and I want it to be xls what should I do

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()