HSSFCellStyle style = null
// 创建表头style
HSSFCellStyle cellStyleTitle = workbook.createCellStyle()
cellStyleTitle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND)// 填充单元格
cellStyleTitle.setFillForegroundColor(HSSFColor.YELLOW.index)
cellStyleTitle.setAlignment(HSSFCellStyle.ALIGN_CENTER)// //居中显示
HSSFRow titleRow = sheet.createRow(0)
for (int i = 0i <titles.lengthi++) {
HSSFCell cell = titleRow.createCell(i)
// cell.setCellStyle(createCellColorStyle(workbook))
cell.setCellStyle(cellStyleTitle)
cell.setCellValue(titles[i])// 给单元格赋值
}
不知道能,看懂不,如果有不清楚的私聊
//换成下面代码试试ICellStyle style2 = hssfworkbook.CreateCellStyle()
style2.BorderBottom = NPOI.SS.UserModel.BorderStyle.THIN
style2.BorderLeft = NPOI.SS.UserModel.BorderStyle.THIN
style2.BorderRight = NPOI.SS.UserModel.BorderStyle.THIN
style2.BorderTop = NPOI.SS.UserModel.BorderStyle.THIN
style2.BorderDiagonal = BorderDiagonal.BACKWARD
style2.BorderDiagonalLineStyle = NPOI.SS.UserModel.BorderStyle.THIN
style2.Alignment = NPOI.SS.UserModel.HorizontalAlignment.LEFT
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)