zoukankan      html  css  js  c++  java
  • 在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();

  • 相关阅读:
    HTTP
    jQuery
    BOM与DOM
    Page类成员
    Web用户自定义控件
    ASP.NET服务端基本控件介绍
    ASP.NET中的验证控件
    ASP.NET数据绑定控件
    ASP.NET中的母版页
    ASP.NET缓存 Cache
  • 原文地址:https://www.cnblogs.com/gossip/p/1954714.html
Copyright © 2011-2022 走看看