在asp.net里,从DataSet/DataTable, Gridview导出excel到前端的问题经常遇到,我开始用的方法是:
之所以用ApplicationInstance.CompleteRequest()是为了避免System.Threading.ThreadAbortException异常,但是问题巧好就处在ApplicationInstance.CompleteRequest();上。如果用的是ApplicationInstance.CompleteRequest(),那么response输出的除了xml以外,还会在excel文件的后面加当前页面的html。如果用的是Response.End(),那么就只输出xml. 原因没空研究,先记着。