• 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();

  • 相关阅读:
    原码、反码、补码,计算机中负数的表示
    java 解惑系列
    (转载) 深入JVM学习笔记-安全性
    理解Java对象序列化
    关于Arrays.asList 函数的一些 陷阱
    JAVA设计模式之单例模式 (转载)
    Educational Codeforces Round 76 D
    总结
    bzoj3531: [Sdoi2014]旅行 (树链剖分 && 动态开点线段树)
    bzoj3626: [LNOI2014]LCA (树链剖分)
  • 原文地址:https://www.cnblogs.com/hanxingli/p/5316067.html
Copyright © 2020-2023  润新知