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

  • 相关阅读:
    Thawte SSL Web Server 多域型SSL证书
    易维信(EVTrust)支招五大技巧识别钓鱼网站
    Thawte SSL Web Server
    Thawte 企业版代码签名证书
    python数据分析(四)
    python数据分析(三)
    python数据分析(二)
    python数据分析(一)
    MSQL基础知识
    c#中调用c++程序
  • 原文地址:https://www.cnblogs.com/hanxingli/p/5316067.html
Copyright © 2020-2023  润新知