我使用以下方法来定义工作表中的单元格样式。然后,我使用 cell.setCellStyle(XSSFCellStyle style)
将其分配给不同的单元格。
但是,虽然对齐和背景颜色被正确分配,但字号和字体强调(粗体、普通)则没有。所有单元格都有11点粗体。我想知道我的错误在哪里。
private void createStyles() {
ueberschrift = workbook.createCellStyle();
ueberschrift.setAlignment(HorizontalAlignment.LEFT);
ueberschrift.getFont().setFontHeightInPoints((short) 25);
ueberschrift.getFont().setBold(true);
header = workbook.createCellStyle();
header.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
header.setFillPattern(FillPatternType.SOLID_FOREGROUND);
header.setAlignment(HorizontalAlignment.CENTER);
header.getFont().setFontHeightInPoints((short)11);
standard_text = workbook.createCellStyle();
standard_text.setAlignment(HorizontalAlignment.RIGHT);
standard_text.getFont().setFontHeightInPoints((short) 11);
standard_int = workbook.createCellStyle();
standard_int.setDataFormat(
workbook.createDataFormat().getFormat("0.0"));
standard_int.setAlignment(HorizontalAlignment.RIGHT);
standard_int.getFont().setFontHeightInPoints((short)11);
standard_time = workbook.createCellStyle();
standard_time.setDataFormat(workbook.createDataFormat().getFormat("# ?/?"));
standard_time.setAlignment(HorizontalAlignment.RIGHT);
}