• 导出EXCEL


     private void CreateExcel()
            {
                string header = string.Empty;
                string line = string.Empty;

                try
                {
                   
                    dltDataBind();

                    Response.Clear();
                    Response.Buffer = true;
                    Response.Charset = "utf-8";
                    Response.AppendHeader("Content-Disposition", "attachment;filename=orginfo.xls");
                    Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
                    header = "拜访时间 " +"机构名 " +"所在地 " + "客户类别 " +"销售方式 " +"拜访方式 " + "销售员 " +"是否集体培训 " + "拜访人 " + "撰写人 " + "最后修改时间 ";

                    Response.Write(header.ToString());

                    DataTable dt = ds.Tables[0];

                    int rows = 1;
                    //逐行处理数据   
                    foreach (DataRow dr in dt.Rows)
                    {

                        line = string.Empty;//dt.Rows.IndexOf(dr);

                        //在当前行中,逐列获得数据,数据之间以 分割,结束时加回车符
                        line = rows.ToString() + " " + DealWithValue(dr["bfqssj"]).ToString() + " " +
                            DealWithValue(dr["org_name"]).ToString() + " " +
                            DealWithValue(dr["org_area"]).ToString() + " " +
                            DealWithValue(dr["khlb"]).ToString() + " " +
                            DealWithValue(dr["sale_process"]).ToString() + " " +
                            DealWithValue(dr["bffs"]).ToString() + " " +
                            DealWithValue(dr["saler"]).ToString() + " " +
                            DealWithValue(dr["ass_saler"]).ToString() + " " +
                             DealWithValue(dr["is_jtpx"]).ToString() + " " +
                              DealWithValue(dr["unames"]).ToString() + " " +
                               DealWithValue(dr["operater"]).ToString() + " " +
                                DealWithValue(dr["op_date"]).ToString() + " " +  
                            " ";

                        rows = rows +1;
                        //当前行数据写入HTTP输出流
                        Response.Write(line);
                    }

                    //写缓冲区中的数据到HTTP头文件中
                    Response.End();

                }

                catch (Exception ex)
                {
                    Console.Write(ex.ToString());
                }
            }  
           
            protected void btnoutex_Click1(object sender, EventArgs e)
            {
                CreateExcel();
            }

  • 相关阅读:
    结对第一次—疫情统计可视化(原型设计)
    寒假作业(2/2)
    寒假作业(1/2)
    android 全局悬浮窗的使用以及权限
    个人作业——软件工程实践总结&个人技术博客
    个人作业——软件评测
    结对第二次作业——某次疫情统计可视化的实现
    软工实践寒假作业(2/2)
    软工实践寒假作业(1/2)
    蒟蒻博主又回来了
  • 原文地址:https://www.cnblogs.com/liupengfei19940119/p/3755712.html
Copyright © 2020-2023  润新知