通过流打开一个Excel文件

            string templateExcel = "xxx.xls";
            string path = Server.MapPath(@"Template\") + templateExcel; //路径
            System.IO.FileInfo file = new System.IO.FileInfo(path);
            Response.AddHeader("Content-Disposition", "attachment;  filename=" + HttpUtility.UrlEncode(file.Name));
            Response.AddHeader("Content-Length", file.Length.ToString());
            Response.ContentType = "application/octet-stream";
            Response.WriteFile(file.FullName);
            Response.End();
原文地址:https://www.cnblogs.com/andycai/p/1750703.html