I found the solution to it. The issue was due to another Response.Write() code was written on Page load due to which the issue in excel file was coming.
Response.Write("<script language='javascript'>" & Chr(10))
Response.Write("</script>" & Chr(10))
The moment I commented the same, it worked.