Workbook wb = new XSSFWorkbook("myWorkbook.xlsx"); Row row=sheet.getRow(0); CellStyle style=null; XSSFFont defaultFont= wb.createFont(); defaultFont.setFontHeightInPoints((short)10); defaultFont.setFontName("Arial"); defaultFont.setColor(IndexedColors.BLACK.getIndex()); defaultFont.setBold(false); defaultFont.setItalic(false); XSSFFont font= wb.createFont(); font.setFontHeightInPoints((short)10); font.setFontName("Arial"); font.setColor(IndexedColors.WHITE.getIndex()); font.setBold(true); font.setItalic(false); style=row.getRowStyle(); style.setFillBackgroundColor(IndexedColors.DARK_BLUE.getIndex()); style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setAlignment(CellStyle.ALIGN_CENTER); style.setFont(font);
private void fillHeaderRow(XSSFWorkbook xssfWorkbook, XSSFSheet sheet, Integer rowNum, Locale locale) { XSSFRow headerLine = sheet.createRow(rowNum); XSSFFont font = xssfWorkbook.createFont(); font.setFontHeightInPoints((short) 10); font.setFontName("ARIAL"); font.setItalic(false); font.setBold(true); font.setBoldweight(Font.BOLDWEIGHT_BOLD); font.setColor(HSSFColor.BLACK.index); XSSFCellStyle style = xssfWorkbook.createCellStyle(); style.setFont(font); Lists.newArrayList(MaintenanceEventsElementsReportEnum.values()).forEach( e -> createHeaderCell(e, headerLine, style, locale)); }
public void setBoldweight(short boldweight) { setBold(boldweight == BOLDWEIGHT_BOLD); }
private void fillHeaderRow(final XSSFWorkbook workbook, final XSSFSheet sheet, Integer rowNum, final Locale locale) { XSSFRow headerLine = sheet.createRow(rowNum); XSSFFont font = workbook.createFont(); font.setFontHeightInPoints((short) 10); font.setFontName("ARIAL"); font.setItalic(false); font.setBold(true); font.setBoldweight(Font.BOLDWEIGHT_BOLD); font.setColor(HSSFColor.BLACK.index); XSSFCellStyle style = workbook.createCellStyle(); style.setFont(font); int colNumber = 0; for (String column : PlannedEventsXlsConstants.ALL_COLUMNS) { XSSFCell headerCell = headerLine.createCell(colNumber); headerCell.setCellValue(translationService.translate(column, locale)); headerCell.setCellStyle(style); colNumber++; } }
XSSFWorkbook wb=new XSSFWorkbook(); XSSFFont font = wb.createFont(); font.setBold( true ); font.setItalic( true ); new XSSFRichTextString().applyFont( font );
font.setFontName("ARIAL"); font.setItalic(false); font.setBold(true); font.setBoldweight(Font.BOLDWEIGHT_BOLD);
font.setBold(true); bold.setFont(font); bold.setAlignment(HorizontalAlignment.CENTER);
font.setFontName("ARIAL"); font.setItalic(false); font.setBold(false); font.setBoldweight(Font.BOLDWEIGHT_NORMAL);
font.setBold(bold);
@Override public void prepareColumn(TableModel tableModel, XSSFSheet sheet, int col) { XSSFWorkbook wb = sheet.getWorkbook(); XSSFDataFormat df = wb.createDataFormat(); cellStyle = wb.createCellStyle(); XSSFFont f = wb.createFont(); f.setFontHeightInPoints((short) 12); f.setBold(true); f.setColor(IndexedColors.BLACK.getIndex()); cellStyle.setFont(f); cellStyle.setDataFormat(df.getFormat("text")); cellStyle.setBorderTop(CellStyle.BORDER_THIN); cellStyle.setBorderColor(BorderSide.TOP, new XSSFColor(new Color(0, 0, 0))); cellStyle.setBorderRight(CellStyle.BORDER_THIN); cellStyle.setBorderColor(BorderSide.RIGHT, new XSSFColor(new Color(0, 0, 0))); cellStyle.setBorderBottom(CellStyle.BORDER_THIN); cellStyle.setBorderColor(BorderSide.BOTTOM, new XSSFColor(new Color(0, 0, 0))); cellStyle.setBorderLeft(CellStyle.BORDER_THIN); cellStyle.setBorderColor(BorderSide.LEFT, new XSSFColor(new Color(0, 0, 0))); }
font1.setBold(true); font1.setColor(new XSSFColor(new java.awt.Color(255, 0, 0), wb.getStylesSource().getIndexedColors())); rt.applyFont(0, 10, font1);
private static CellStyle getHeaderCellStyle(XSSFWorkbook wb){ // Cell Style XSSFCellStyle cellStyle = wb.createCellStyle(); XSSFFont font = wb.createFont(); // Font // font.setColor(HSSFColor.RED.index); font.setBold(true); font.setFamily(FontFamily.MODERN); // font.setFontHeight((short)300); cellStyle.setFont(font); // Align cellStyle.setAlignment(HorizontalAlignment.CENTER); // Border Line // cellStyle.setBorderTop(BorderStyle.THICK); // cellStyle.setBorderBottom(BorderStyle.DASH_DOT); // cellStyle.setBorderLeft(BorderStyle.DASHED); // cellStyle.setBorderRight(BorderStyle.DASHED); // Foreground color cellStyle.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index); cellStyle.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND); return cellStyle; }
private void metricsHeader(final XSSFSheet sheet, final EvaluationMetadata metadata) { final XSSFRow header = sheet.createRow(1); final CellStyle bold = sheet.getWorkbook().createCellStyle(); final XSSFFont font = sheet.getWorkbook().createFont(); font.setBold(true); bold.setFont(font); bold.setAlignment(HorizontalAlignment.CENTER); font.getCTFont().addNewB(); final AtomicInteger counter = new AtomicInteger(0); metadata.metrics .forEach(name -> { final int columnIndex = 3 + (counter.getAndIncrement() * ((metadata.howManyVersions() * 2) - 1)); final Cell qgHeaderCell = header.createCell(columnIndex, CellType.STRING); qgHeaderCell.setCellValue(name); qgHeaderCell.setCellStyle(bold); try { sheet.addMergedRegion( new CellRangeAddress( header.getRowNum(), header.getRowNum(), columnIndex, columnIndex + ((metadata.howManyVersions() * 2) - 2))); } catch (final Exception ignore) { } }); }
boldFont.setBold( true );
headerFont.setBold(true); style5.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); style5.setFillPattern(FillPatternType.SOLID_FOREGROUND);
monthFont.setFontHeightInPoints((short)12); monthFont.setColor(new XSSFColor(new java.awt.Color(255, 255, 255), wb.getStylesSource().getIndexedColors())); monthFont.setBold(true); style = wb.createCellStyle(); style.setAlignment(HorizontalAlignment.CENTER); dayFont.setBold(true); style = wb.createCellStyle(); style.setAlignment(HorizontalAlignment.LEFT);
headerFont.setBold(true); rowHeaderStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); rowHeaderStyle.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND);
font.setColor(indexedColor); font.setBold(boldWeight); font.setFontHeight(fontHeight); font.setFontName(name);
font.setColor(indexedColor); font.setBold(boldWeight); font.setFontHeight(fontHeight); font.setFontName(name);