NPOI2.0学习(三)
2016-04-06 05:36
337 查看
HSSFWorkbook wk = new HSSFWorkbook();//你用来操作的HSSFWorkbook的实例 ICellStyle cellStyle = wk.CreateCellStyle();
ICellStyle cellStyle = wk.CreateCellStyle(); //设置单元格上下左右边框线 cellStyle.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin; cellStyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin; cellStyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin; cellStyle.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin; //文字水平和垂直对齐方式 cellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center; cellStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center; //是否换行 //cellStyle.WrapText = true; //缩小字体填充 cellStyle.ShrinkToFit = true; ICellStyle style2 = wb.CreateCellStyle();//样式 IFont font1 = wb.CreateFont();//字体 font1.FontName = "楷体"; font1.Color = HSSFColor.Red.Index;//字体颜色 font1.Boldweight = (short)FontBoldWeight.Normal;//字体加粗样式 style2.SetFont(font1);//样式里的字体设置具体的字体样式 //设置背景色 style2.FillForegroundColor = NPOI.HSSF.Util.HSSFColor.Yellow.Index; style2.FillPattern = FillPattern.SolidForeground; style2.FillBackgroundColor = NPOI.HSSF.Util.HSSFColor.Yellow.Index; style2.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Left;//文字水平对齐方式 style2.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center;//文字垂直对齐方式
ICell Cell = sheet.CreateRow(0).CreateCell(0); Cell.CellStyle = cellStyle; Cell.SetCellValue("测试格式效果");
ICellStyle newCellStyle = wk.CreateCellStyle(); newCellStyle.CloneStyleFrom(cellStyle); newCellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Left;
相关文章推荐
- 230. Kth Smallest Element in a BST
- LeetCode 233. Number of Digit One
- JSP+DAO实现数据库的CRUD
- lintcode-medium-Single Number II
- [Angular 2] Property Binding
- lintcode-medium-Simplify Path
- LeetCode "Flatten Nested List Iterator"
- 用WinRAR进行安装包的制作
- 概率分布及其统计特性
- AU3学习资源
- PHP之Http请求
- CruiseControl.NET开篇
- lintcode-medium-Set Matrix Zeroes
- The remote SSH server rejected X11 forwarding request
- The remote SSH server rejected X11 forwarding request
- The remote SSH server rejected X11 forwarding request
- 德国的挑战 - 中国制造2025
- 正则例一
- WM_ERASEBKGND官方解释(翻译),以及Delphi里所有的使用情况(就是绘制窗口控件背景色,并阻止进一步传递消息)
- Java---设计模式app小软件汇总应用