downExcel.aspx,以下代码放在页面的page_load里面
string filePath = Request.QueryString["filePath"];
string fileName = Request.QueryString["fileName"];
FileInfo fileInfo = new FileInfo(filePath);
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName);
Response.AddHeader("Content-Length", fileInfo.Length.ToString());
Response.AddHeader("Content-Transfer-Encoding", "utf-8");
Response.ContentType = "application/octet-stream";
Response.ContentType = "application/ms-excel";//设置输出文件类型为excel文件。
Response.ContentEncoding = System.Text.Encoding.Default;
Response.WriteFile(fileInfo.FullName);
Response.Flush();
Response.End();