zoukankan      html  css  js  c++  java
  • 创建一个的excel工作薄 导出Excel

     1     // <summary>
     2     /// 创建一个的excel工作薄-
     3     /// </summary>
     4     /// <returns></returns>
     5     public void InputExcel()
     6     {
     7         try
     8         {
     9             //Instantiate a new workbook
    10             Workbook workbook = new Workbook();
    11             workbook.Worksheets[0].Name = "我的工作薄";
    12             //Set default font
    13             Aspose.Cells.Style style = workbook.DefaultStyle;
    14             style.Font.Name = "Tahoma";
    15             workbook.DefaultStyle = style;
    16 
    17             Cells cells = workbook.Worksheets[0].Cells;
    18             cells.InsertRow(0);
    19             for (int j = 0; j < 2; j++)
    20             {
    21                 Cell cell = cells[0, j];//i行j列
    22                 #region 生成表头
    23                 if (j == 0)
    24                 {
    25                     cell.PutValue("员工姓名");
    26                 }
    27                 if (j == 1)
    28                 {
    29                     cell.PutValue("邮箱");
    30                 }
    31                 #endregion
    32             }
    33             //return workbook;
    34             String filename = string.Format("{0}{1}.xls", "saleranklist", Convert.ToDateTime(DateTime.Now).ToString("yyyyMMdd")); //文件默认命名方式,可以自定义
    35             Response.ContentType = "application/ms-excel;charset=utf-8";
    36             Response.AddHeader("content-disposition", "attachment; filename=" + filename);
    37             System.IO.MemoryStream memStream = workbook.SaveToStream();
    38             Response.BinaryWrite(memStream.ToArray());
    39             Response.End();
    40 
    41         }
    42         catch (System.Exception ex)
    43         {
    44 
    45         }
    46     }
  • 相关阅读:
    理解闭包Closure
    理解商集
    理解格
    理解距(数学)
    微积分英文词汇,高数名词中英文对照,高等数学术语英语翻译一览
    对Extjs中store的多种操作
    mysql中的除法取整
    【python】用asq实现count(distinct cln)
    Timer 和TimerTask的使用
    使用vim.rc配置vim
  • 原文地址:https://www.cnblogs.com/chenghu/p/3116636.html
Copyright © 2011-2022 走看看