zoukankan      html  css  js  c++  java
  • 字符串导出word

    protected void Page_Load(object sender, EventArgs e)
    {
    this.WriteToDoc("个人资料", "application/vnd.doc", "内容:我的名字是“静静地”");
    }
    private void WriteToDoc(string FileName, string FileType, string FileTxt)
    {
    //清除反冲区的内容
    Response.Clear();
    //设置输出流的HTTP字符集
    Response.Charset = "gb2312";
    //将一个HTTP头添加到输出流
    HttpBrowserCapabilities hbc = System.Web.HttpContext.Current.Request.Browser;
    string browserType = hbc.Browser.ToString().ToLower();
    if (browserType == "firefox")
    {
    Response.AddHeader("Content-Disposition", "attachment;filename=" +FileName+ ".doc");
    }
    else
    {
    Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(Encoding.UTF8.GetBytes(FileName+".doc")));
    }
    // Response.AddHeader("content-disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, System.Text.Encoding.UTF8) + ".doc");
    //设置输出的HTTP MIME类型
    Response.ContentType = FileType;
    System.Text.StringBuilder sb = new System.Text.StringBuilder();
    sb.Append(FileTxt);
    //把字符数组写入HTTP响应输出流
    Response.Write(sb.ToString());
    //发送完,关闭
    Response.End();
    }

  • 相关阅读:
    基于朴素贝叶斯的书籍评价信息分类任务
    贝叶斯原理
    knn算法手写字识别案例
    knn原理及借助电影分类实现knn算法
    航空公司案列分析
    k-meanas原理自实现
    df认识
    箱线图
    pandas认识
    分析system_call中断处理过程
  • 原文地址:https://www.cnblogs.com/ggbbeyou/p/2965452.html
Copyright © 2011-2022 走看看