zoukankan      html  css  js  c++  java
  • 从数据库导出到excel

    在项目 扬中 News shenbaocreateall

    //选中的id 

    string cc = Request["IDcheck"];
                Response.Clear();
                Response.Buffer = true;
                Response.AppendHeader("Content-Disposition", "attachment;filename=" + DateTime.Now.ToString("yyyyMMdd") + ".xls");
           //这里注意编码方式    

    Response.ContentEncoding = System.Text.Encoding.Default;
                Response.ContentType = "application/vnd.ms-excel";

     StringBuilder sb = new StringBuilder("");
                sb.Append("申请类别(创新创业)</b>");
                sb.Append("\t");
                sb.Append("申请类别(单位个人)");
                sb.Append("\t");

      sb.Append("\n");
                Response.Write(sb.ToString());

                sb.Clear();
                string[] cc_arry =cc.Split(new char[]{','});


                //for
                for(int i=0;i<cc_arry.Length ;i++)
                {
                    int id = Convert.ToInt32(cc_arry[i]);
                    shenbao getmodel = db.shenbaos.Find(id);

      sb.Append(getmodel.Type);
                sb.Append("\t");
                sb.Append(getmodel.PersonType);
                sb.Append("\t");
                sb.Append(getmodel.LuoHuDiQu);
                sb.Append("\t");
                sb.Append(getmodel.name);
                sb.Append("\t");

      sb.Append(getmodel.IsYouHeZuo);

    //最后一个 是\n
                       sb.Append("\n");

      }
                Response.Write(sb.ToString());
                Response.End();

  • 相关阅读:
    [模板] 主席树
    [模板] 替罪羊树
    [模板] Treap
    [LUOGU] P4342 [IOI1998]Polygon
    [JOYOI] 1051 选课
    poj 1845 数论(唯一分解定理+分治法求等比数列前n项的和mod m的值)
    poj 2418 bst统计字符串
    hdu 3791 二叉排序树
    hdu 3999 二叉排序树
    toj 3711 水题
  • 原文地址:https://www.cnblogs.com/heifengwll/p/3473306.html
Copyright © 2011-2022 走看看