winform npoi excel 样式设置
生活随笔
收集整理的這篇文章主要介紹了
winform npoi excel 样式设置
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
IWorkbook excel = new HSSFWorkbook();//創建.xls文件ISheet sheet = excel.CreateSheet("sheet1"); //創建sheetint rowindex = 0;IRow row = sheet.CreateRow(rowindex++);//創建一行ICell cell = row.CreateCell(0);//創建一列
cell.SetCellValue(linkLabel1.Text);ICellStyle style = excel.CreateCellStyle();//設置單元格的樣式:水平對齊居中style.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;//新建一個字體樣式對象IFont font = excel.CreateFont();//設置字體加粗樣式//font.Boldweight = short.MaxValue;//設置字體大小font.FontHeightInPoints = 15;//使用SetFont方法將字體樣式添加到單元格樣式中
style.SetFont(font);//將新的樣式賦給單元格cell.CellStyle = style;//設置單元格的高度//row.Height = 20 * 20;////設置單元格的寬度//sheet.SetColumnWidth(0, 30 * 256);sheet.AddMergedRegion(new CellRangeAddress(0, 0, 0, strArr.Length-1));
?
轉載于:https://www.cnblogs.com/aj407blogs/p/9780454.html
總結
以上是生活随笔為你收集整理的winform npoi excel 样式设置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 营销 | 10个助燃商业增长的市场营销战
- 下一篇: JavaScript实现页面滚动到div