zoukankan      html  css  js  c++  java
  • C# 将数据集以excel的形式输出

    private void SaveLastMonthAuthorPays()
            {
                string fileName = "LastMonthAuthorPays.xls";

                string contentFormat = "{0} {1} {2} {3} {4} ";

                DataSet ds = null;

                AuthorPayManager authorPayManager = new AuthorPayManager();
                try
                {
                    ds = authorPayManager.LoadLastMonthAuthorPays();
                }
                catch (Exception ex)
                {
                    //LogHelper.Warn("获取上月应支付稿酬列表时出现错误," + ex.ToString());
                    AddUserLogEx("获取上月应支付稿酬列表时出现错误," + ex.ToString(), LogOPType.Insert);
                    this.RedirectErrorPage("获取上月应支付稿酬列表时出现错误,请与管理员联系");
                }

                Response.ClearHeaders();
                Response.Clear();
                Response.Expires = 0;
                Response.Buffer = true;
                Response.AddHeader("Accept-Language", "zh-cn");

                Response.AddHeader("content-disposition", "attachment; filename=" + fileName);
                Response.ContentType = "Application/ms-excel";
                Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");

                Response.Write("支付月份 当月支付稿酬 半年奖励 稿酬类型 作家署名 ");
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    Response.Write(string.Format(contentFormat,
                        dr["moneytime"],//支付月份
                        dr["money"],        //当月支付稿酬
                        dr["money_level"],             //半年奖励
                        dr["nature"],        //
                        dr["aut_name"]      //作家署名
                        )
                    );
                }

                Response.End();
            }

  • 相关阅读:
    相信未来 ————11月份做题记录
    noi 滚cu后7月oi生活
    博客已经迁移到 http://imbotao.top 也会同步到这儿
    构建第一个SpringBoot工程
    Spring 事务管理
    IntelliJ IDEA 使用技巧
    JS 获取字符串实际长度
    读《程序员修炼之道》
    读《如何高效学习》
    SQL 语句优化方法
  • 原文地址:https://www.cnblogs.com/niaowo/p/3603532.html
Copyright © 2011-2022 走看看