zoukankan      html  css  js  c++  java
  • .net 对word的在线操作

    下面代码把datagrid生成了word文档,并在ie显示
    //生成
    HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=RoadRepair.doc"); /?"
    Response.ContentType = "application/vnd.ms-word"  ;//指定生成文件的类型
    HttpContext.Current.Response.Charset = "";
    HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default;
    System.IO.StringWriter tw=new  System.IO.StringWriter();
    System.Web.UI.HTMLTextWriter hw=new System.Web.UI.HTMLTextWriter(tw)
    DataGrid1.RenderControl(hw);//datagrid转成string
    HttpContext.Current.Response.Write(hw.tosting());
    HttpContext.Current.Response.End();

    //显示
    Response.ClearContent();
    Response.ClearHeaders();
    Response.ContentType="application/msword";
    Response.WriteFile("RoadRepair.doc");
    Response.Flush();
    Response.Close();

  • 相关阅读:
    ElementUi
    Vue插件
    Vue-cli
    Vue进阶
    Vue组件
    Vue生命期钩子
    Vue基础
    Vue介绍
    logging模块
    time模块
  • 原文地址:https://www.cnblogs.com/zhangsir/p/1115733.html
Copyright © 2011-2022 走看看