在IE中打开Excel和Word(2003格式测试通过)

           //在浏览其中打开word文件

            Response.ClearContent();

            Response.ClearHeaders();

            Response.ContentType = "Application/msword";

            string strFilePath = "";

            strFilePath = Server.MapPath("高手帮你学习LINQ.doc");  //Word路径

            FileStream fs = new FileStream(strFilePathFileMode.OpenOrCreateFileAccess.Read);

            Response.WriteFile(strFilePath, 0, fs.Length);

            fs.Close();

   

            //在浏览其中打开Excel文件

            Response.ClearContent();

            Response.ClearHeaders();

            Response.ContentType = "application/vnd.ms-excel";

            Response.WriteFile(Server.MapPath("Book1.xls")); //Excel路径

            Response.Flush();

            Response.Close();

posted @ 2011-02-14 22:04    阅读(693)  评论(0编辑  收藏  举报