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