zoukankan      html  css  js  c++  java
  • Aspose Cells dll 实现数据简单下载

                       Workbook workbook = new Workbook(); //工作簿
                        Worksheet sheet = workbook.Worksheets[0]; //工作表
                        sheet.AutoFitRows();
                        sheet.Name = "下载列表";
                        Cells cells = sheet.Cells;//单元格
                        Aspose.Cells.Style style = workbook.Styles[workbook.Styles.Add()];//新增样式
                        //标题
                        style.HorizontalAlignment = TextAlignmentType.Left;//文字左对齐 
                        style.Font.Name = "微软雅黑";//文字字体
                        style.Font.Size = 9;//文字大小 
                        style.HorizontalAlignment = TextAlignmentType.Center;
                        style.ForegroundColor = System.Drawing.Color.Red;

                          // 文件头

                          int cellLength = IncomeHeadline.Length;                  

                           for (int i = 0; i < IncomeHeadline.Length; i++)                   

                          {                        

                                   cells.SetColumnWidth(i, 15);  cells[0, i].PutValue(IncomeHeadline[i]);   //填写内容

                                   var strCell = cells[0, i].GetStyle();  strCell.ForegroundColor =Color.DodgerBlue;                                                   

                                   strCell.Font.Color = Color.White;  strCell.Font.Size = 12;strCell.Pattern = BackgroundType.Solid;  

                                   cells[0, i].SetStyle(strCell);                  

                         }

                       //下载设置

                       HttpContext curContext = HttpContext.Current;
                        // 设置编码和附件格式  
                        curContext.Response.ContentType = "application/vnd.ms-excel";
                        curContext.Response.ContentEncoding = Encoding.UTF8;
                        var fileName = "123“+ ".xls";
                        curContext.Response.AppendHeader("Content-Disposition",
                            "attachment;filename=" + HttpUtility.UrlEncode(fileName, Encoding.UTF8));
                        System.IO.MemoryStream ms = workbook.SaveToStream();//生成数据流
                        byte[] bt = ms.ToArray();
                        curContext.Response.BinaryWrite(bt);
                        curContext.Response.End();

  • 相关阅读:
    [android] 实现返回键操作思路
    [android] 切换界面的问题
    [android] 切换界面的通用处理
    [android] 界面切换的简单动画
    [android] 界面切换的核心方法
    [android] 标题部分管理
    [android] 界面的划分
    [android] socket在手机上的应用
    [android] 网络链接类型和渠道
    [android] android通信协议
  • 原文地址:https://www.cnblogs.com/hanxingli/p/5316067.html
Copyright © 2011-2022 走看看