C# Excel导出后台代码
FileStream fileStrem = new FileStream(templatePath, FileMode.Open); long fileSize = fileStrem.Length; Context.Response.ContentType = "application/octet-stream"; Context.Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode("任务模板.xlsx", Encoding.UTF8)); Context.Response.AddHeader("Content-Length", fileSize.ToString()); byte[] fileBuffer = new byte[fileSize]; fileStrem.Read(fileBuffer, 0, (int)fileSize); Context.Response.BinaryWrite(fileBuffer); Context.Response.End();