You need to understand that ASP.NET is not the same as Classic ASP you cannot use Response.Write any old place you want, it breaks the control rendering model when used incorrectly. You cannot do it in an UpdatePanel for example. To download a file you can use Response.Write but not while also rendering other controls or html, a download request must be all by itself and the response should contain only the file and nothing else.
There is example code in mojoPortal similar to what you are trying to do but exporting to csv. you can study the ExportaDataTableToCsv method in the ExportHelper.cs and an example where it is called is in btnExport_Click in LetterSubscribers.aspx.cs
To figure out what is going on you should set breakpoints and step through your code.
Hope that helps,
Joe