This is because you are not even trying to write anything in Excel format. If you use Excel's content type, it simply means that you misrepresent the data you write in your HTTP response, which is in fact some tab-separated and end-of-line-separated content. It would work if you started Excel application and used this file for import, but then its content type would have to be text/plain.
If you create a file with such content and name it as, say, test.txt, Excel will open it, but if you name it test.xls, Excel says: "Excel cannot open the file 'test.xlsx', because the file format of the file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file". This is what would observe if you save content in an Excel file; if you choose to open content with Excel via the URL, it could be something simple — you did not report how the problem is manifested, and, naturally, I never tried to do such weird thing.
What to do? If you claim the content is "text/plain", it also might be not good enough, because you don't want the browser to open it in the browser page (however, your disposition header can prevent it). Maybe you have to deliver native Excel format, which is Microsoft Open XML format. Please see:
Creating basic Excel workbook with Open XML,
How to add microsoft excel 15.0 object library from Add Reference in MS Visual Studio 2010.
If you want to find some code sample closer to your problem, one of the good places to search for is CodeProject.
I just found this demo, please see:
Write data to Excel file (.xls and .xlsx) in ASP.Net.
—SA