NPOI 1.2.3教程 -11 边框样式BorderStyle
2011-01-23 15:49
1951 查看
using System; using System.Text; using System.IO; using NPOI.HSSF.UserModel; using NPOI.HSSF.Util; using NPOI.HPSF; using NPOI.POIFS.FileSystem; using NPOI.SS.UserModel; namespace SetBorderStyleInXls { class Program { static void Main(string[] args) { InitializeWorkbook(); Sheet sheet = hssfworkbook.CreateSheet("new sheet"); // Create a row and put some cells in it. Rows are 0 based. Row row = sheet.CreateRow(1); // Create a cell and put a value in it. Cell cell = row.CreateCell(1); cell.SetCellValue(4); // Style the cell with borders all around. CellStyle style = hssfworkbook.CreateCellStyle(); style.BorderBottom= CellBorderType.THIN; style.BottomBorderColor= HSSFColor.BLACK.index; style.BorderLeft = CellBorderType.DASH_DOT_DOT; style.LeftBorderColor= HSSFColor.GREEN.index; style.BorderRight = CellBorderType.HAIR; style.RightBorderColor= HSSFColor.BLUE.index; style.BorderTop = CellBorderType.MEDIUM_DASHED; style.TopBorderColor= HSSFColor.ORANGE.index; cell.CellStyle= style; WriteToFile(); } static HSSFWorkbook hssfworkbook; static void WriteToFile() { //Write the stream data of workbook to the root directory FileStream file = new FileStream(@"test.xls", FileMode.Create); hssfworkbook.Write(file); file.Close(); } static void InitializeWorkbook() { hssfworkbook = new HSSFWorkbook(); //Create a entry of DocumentSummaryInformation DocumentSummaryInformation dsi = PropertySetFactory.CreateDocumentSummaryInformation(); dsi.Company = "NPOI Team"; hssfworkbook.DocumentSummaryInformation = dsi; //Create a entry of SummaryInformation SummaryInformation si = PropertySetFactory.CreateSummaryInformation(); si.Subject = "NPOI SDK Example"; hssfworkbook.SummaryInformation = si; } } }
相关文章推荐
- Flex中如何通过borderStyle和borderSides样式设置NumericStepper控件特定边框(上下左右边)的例子
- 动态调整对话框属性(去掉标题栏,去掉边框,修改类似成Border:NONE样式)(调用ModifyStyle和ModifyStyleEx,然后调用SetWindowPos重新显示)
- 边框样式[border-style]
- border-bottom-style(下边框的样式)
- 【自学笔记】css 各类边框样式 属性border-style
- NPOI 1.2.3教程 -25 条件样式ConditionalFormat
- CSS border边框属性教程(color style)
- POI 边框样式BorderStyle
- CSS border边框属性教程(color style)
- CSS border-right-style属性设置元素的右边框样式
- HTML表格标记教程(2):表格的边框属性BORDER
- 如何给div加一个边框border样式
- vue.js入门教程之绑定class和style样式
- 用NPOI创建Excel、合并单元格、设置单元格样式、边框的方法
- NPOI创建Excel﹑合并单元格﹑设置单元格样式﹑边框
- 各种边框样式。。本以为border不是这么用的。
- NPOI 2.0 教程(三):EXCEL 基本格式设置之ICellStyle
- NPOI 1.2.3教程 -18 分组Group
- CSS3简明教程-2.2.CSS3边框之 圆角border-radius
- HTML表格标记教程(13):内部边框样式属性RULES