zoukankan      html  css  js  c++  java
  • 使用Aspose.Cells 过程中用过的知识(转)

    //新建工作簿 
     Workbook workbook = new Workbook(); //工作簿 
     Worksheet sheet = workbook.Worksheets[0]; //工作表 
     Cells cells = sheet.Cells;//单元格 
     
     sheet.Protect(ProtectionType.All, "123123", "");//保护工作表 
     sheet.Protection.IsSelectingLockedCellsAllowed = false;//设置只能选择解锁单元格 
     sheet.Protection.IsFormattingColumnsAllowed = true;//设置可以调整列 
     sheet.Protection.IsFormattingRowsAllowed = true;//设置可以调整行 
     
     Style style1 = workbook.Styles[workbook.Styles.Add()];//新增样式 
     style1.HorizontalAlignment = TextAlignmentType.Center;//文字居中 
     style1.Font.Name = "宋体";//文字字体 
     style1.Font.Size = 12;//文字大小 
     style1.IsLocked = false;//单元格解锁 
     style1.Font.IsBold = true;//粗体 
     style1.ForegroundColor = Color.FromArgb(0x99, 0xcc, 0xff);//设置背景色 
     style1.Pattern = BackgroundType.Solid; //设置背景样式 
     style1.IsTextWrapped = true;//单元格内容自动换行 
     style1.Borders[BorderType.LeftBorder].LineStyle = CellBorderType.Thin; //应用边界线 左边界线 
     style1.Borders[BorderType.RightBorder].LineStyle = CellBorderType.Thin; //应用边界线 右边界线 
     style1.Borders[BorderType.TopBorder].LineStyle = CellBorderType.Thin; //应用边界线 上边界线 
     style1.Borders[BorderType.BottomBorder].LineStyle = CellBorderType.Thin; //应用边界线 下边界线 
     
     cells.Merge(0, 0, 1, 5);//合并单元格 
     cells[0, 0].PutValue("内容");//填写内容 
     cells[0, 0].SetStyle(style1);//给单元格关联样式 
     
     cells.SetRowHeight(0, 38);//设置行高 
     
     cells.SetColumnWidth(1, 20);//设置列宽 
     
     cells[1, 0].Formula = "=AVERAGE(B1:E1)";//给单元格设置计算公式 
     
     System.IO.MemoryStream ms = workbook.SaveToStream();//生成数据流 
     byte[] bt = ms.ToArray(); 
     
     workbook.Save(@"D:\test.xls");//保存到硬盘
  • 相关阅读:

    模块
    18 安装kali系统
    17 部署靶机环境下
    16 部署靶机环境上
    15 部署win2003和IIS服务
    Spring详解(十一)----Bean 的作用域
    Spring详解(十)----使用@Configuration与@Bean注解装配Bean
    Spring详解(九)----Spring Bean的自动装配(基于注解的方式【推荐】)
    Spring详解(八)----Spring Bean的装配(基于注解的方式【推荐】)
  • 原文地址:https://www.cnblogs.com/shenyixin/p/2804750.html
Copyright © 2011-2022 走看看