设置单元格样式
CellStyle Style = workbook.createCellStyle();
XSSFFont font = workbook.createFont();
font.setFontHeightInPoints((short) 11);
font.setFontName("宋体");
font.setBold(true);
Style.setVerticalAlignment(VerticalAlignment.CENTER);
Style.setAlignment(HorizontalAlignment.CENTER);
Style.setBorderBottom(BorderStyle.THIN);
Style.setBorderLeft(BorderStyle.THIN);
Style.setBorderTop(BorderStyle.THIN);
Style.setBorderRight(BorderStyle.THIN);
Style.setFont(font);
参考链接
参考链接
合并单元格
CellRangeAddress region = new CellRangeAddress(1, 2, 3, 4);
sheet.addMergedRegion(region);
注意:一定要先设置将要合并的单元格的格式,再将其合并,否则格式会缺失
参考链接