HSSFCellStyle style = workbook.createCellStyle()
// 设置这些样式
style.setFillForegroundColor(HSSFColor.WHITE.index)
style.setFillPattern(FillPatternType.SOLID_FOREGROUND)
style.setBorderBottom(BorderStyle.THIN)
style.setBorderLeft(BorderStyle.THIN)
style.setBorderRight(BorderStyle.THIN)
style.setBorderTop(BorderStyle.THIN)
style.setAlignment(HorizontalAlignment.CENTER)
HSSFFont FontWhiteBold = workbook.createFont()//创建字体样式FontWhiteBold.setFontHeightInPoints((short)10)//设置字体大小
FontWhiteBold.setFontName("meiryo UI")//设置字体
FontWhiteBold.setColor(HSSFColor.WHITE.index)//设置默认字体颜色白色
FontWhiteBold.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD)
HSSFCellStyle HeaderStyle = (HSSFCellStyle) workbook.createCellStyle()
HeaderStyle.setBorderBottom((short) 1)//设置边框
HeaderStyle.setBorderLeft((short) 1)//设置边框
HeaderStyle.setBorderRight((short) 1)//设置边框
HeaderStyle.setBorderTop((short) 1)//设置边框
HeaderStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER)//单元格内容居中
HeaderStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER)//单元格内容垂直居中
HeaderStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND)//背景
HeaderStyle.setFillForegroundColor(HSSFColor.ROYAL_BLUE.index)//设置背景色蓝
HeaderStyle.setFont(FontWhiteBold)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)