private void Export(string FileType, string FileName) { //设置回应状态 Response.Charset = "GB2312"; Response.ContentEncoding = Encoding.GetEncoding("GB2312"); Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8)); Response.ContentType = FileType; EnableViewState = false; List <Contract> theContractSearch = SearchContract(); ContractCollection theContracts = new ContractCollection(); theContracts.TheContracts = theContractSearch; StringWriter theExcel = theContracts.ExportContractSearchToExcel(); Response.Write(theExcel.ToString()); Response.End(); theExcel.Close(); }