zoukankan      html  css  js  c++  java
  • 生成excel的最简便的方法

              

      string   FileName =  DateTime.Now.Month + DateTime.Now.Day + DateTime.Now.Hour + DateTime.Now.Minute;
                HttpContext.Current.Response.AddHeader("Content-Disposition", "inline;filename=" + HttpUtility.UrlEncode(FileName, System.Text.Encoding.UTF8) + ".xls");
                HttpContext.Current.Response.ContentType = "application/ms-excel";
                DataTable dt = webBll.getExcel();
                int i = 0, j;
                for (i = 0; i < dt.Columns.Count; i++)
                {
                    HttpContext.Current.Response.Write(dt.Columns[i].ToString() + "\t");
                }
                HttpContext.Current.Response.Write("\n");
                foreach (DataRow dr in dt.Rows)
                {
                    for (j = 0; j < dr.ItemArray.Length; j++)
                        HttpContext.Current.Response.Write(dr.ItemArray[j].ToString() + "\t");
                    HttpContext.Current.Response.Write("\n");
                }
                HttpContext.Current.Response.End();

  • 相关阅读:
    OC之class与metaclass
    call vs apply
    ABI
    WEB服务器的四种类型
    情绪控制
    位置无关代码
    Finding Leaks Using Instruments
    Mac之TwoLevel Namespace
    Apache的几个特性
    Mac之debuging symbol
  • 原文地址:https://www.cnblogs.com/yuanws/p/1352982.html
Copyright © 2011-2022 走看看