XSSFFont font = new XSSFFont(ctFont); font.registerTo(_stylesSource); setFont(font); } catch(XmlException e) { throw new POIXMLException(e);
protected void createStyles() { headerStyle = createStyle(null); Font headerFont = workbook.createFont(); headerFont.setBold(true); headerStyle.setFont(headerFont); defaultStyle = createStyle(null); scoreStyle = createStyle(null); scoreStyle.setAlignment(HorizontalAlignment.RIGHT); disabledScoreStyle = createStyle(DISABLED_COLOR); disabledScoreStyle.setAlignment(HorizontalAlignment.RIGHT); unavailableStyle = createStyle(UNAVAILABLE_COLOR); pinnedStyle = createStyle(PINNED_COLOR); hardPenaltyStyle = createStyle(HARD_PENALTY_COLOR); mediumPenaltyStyle = createStyle(MEDIUM_PENALTY_COLOR); softPenaltyStyle = createStyle(SOFT_PENALTY_COLOR); wrappedStyle = createStyle(null); republishedStyle = createStyle(REPUBLISHED_COLOR); }
XSSFCellStyle my_style = (XSSFCellStyle) wb.createCellStyle(); XSSFFont my_font=(XSSFFont) wb.createFont(); my_font.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); my_style.setFont(my_font); XSSFDataFormat df =(XSSFDataFormat) wb.createDataFormat(); my_style.setDataFormat(df.getFormat("#,##0"));
// font/style XSSFFont font = workbook.createFont(); font.setFontName("Arial"); XSSFCellStyle style = workbook.createCellStyle(); style.setFont(font); style.setIndention((short)2); // create/set cell & style cell = row.createCell(0); cell.setCellValue("New Cell"); cell.setCellStyle(style); // auto size spreadsheet.autoSizeColumn(0);
XSSFCellStyle style = workbook.createCellStyle(); style.setBorderTop((short) 6); // double lines border style.setBorderBottom((short) 1); // single line border XSSFFont font = workbook.createFont(); font.setFontHeightInPoints((short) 15); font.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); style.setFont(font); Row row = sheet.createRow(0); Cell cell0 = row.createCell(0); cell0.setCellValue("Nav Value"); cell0.setCellStyle(style); for(int j = 0; j<=3; j++) row.getCell(j).setCellStyle(style);
cell.setCellValue("Header Text"); XSSFCellStyle headerStyle = wb.createCellStyle(); Font headerFont = wb.createFont(); headerStyle.setFillForegroundColor(IndexedColors.GREEN.getIndex()); headerFont.setColor(IndexedColors.WHITE.getIndex()); headerStyle.setFillPattern(CellStyle.SOLID_FOREGROUND); headerStyle.setFont(headerFont); cell.setCellStyle(headerStyle);
XSSFCellStyle hLinkStyle = getWorkbook().createCellStyle(); Font hLinkFont = getWorkbook().createFont(); hLinkFont.setFontName("Ariel"); hLinkFont.setUnderline(Font.U_SINGLE); hLinkFont.setColor(IndexedColors.BLUE.getIndex() ); hLinkStyle.setFont(hLinkFont);
CellStyle createHeaderStyle(Workbook wb){ XSSFCellStyle xstyle = (XSSFCellStyle)wb.createCellStyle(); XSSFColor header = new XSSFColor(new Color(79, 129, 189)); xstyle.setFillForegroundColor(header); xstyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); XSSFFont font = (XSSFFont)wb.createFont(); font.setColor(IndexedColors.WHITE.index); xstyle.setFont(font); return xstyle; }
CellStyle createHeaderStyle(Workbook wb) { XSSFCellStyle xstyle = (XSSFCellStyle) wb.createCellStyle(); XSSFColor header = new XSSFColor(new Color(79, 129, 189)); xstyle.setFillForegroundColor(header); xstyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); XSSFFont font = (XSSFFont) wb.createFont(); font.setColor(IndexedColors.WHITE.index); xstyle.setFont(font); return xstyle; }
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)); }
font.setFontName(fontFamily); style.setFont(font); return style;
@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.setColor(IndexedColors.BLACK.getIndex()); cellStyle.setFont(f); cellStyle.setDataFormat(df.getFormat("m/d/yy h:mm")); }
@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.setColor(IndexedColors.BLACK.getIndex()); cellStyle.setFont(f); cellStyle.setDataFormat(df.getFormat("m/d/yy")); }
private void createHeaders(final Workbook wb, final Sheet sheet) { final Row row = sheet.createRow(HEADERS_ROW_POSITION); final XSSFCellStyle cellStyle = (XSSFCellStyle) wb.createCellStyle(); cellStyle.setAlignment(HorizontalAlignment.CENTER); cellStyle.setFillForegroundColor(new XSSFColor(Color.LIGHT_GRAY)); cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); final Font headerFont = wb.createFont(); headerFont.setBold(true); cellStyle.setFont(headerFont); final CreationHelper creationHelper = wb.getCreationHelper(); for (final CellConfig cellConfig : CellConfig.values()) { final Cell cell = row.createCell(cellConfig.position); cell.setCellValue(creationHelper.createRichTextString(cellConfig.header)); addBordersToCellStyle(cellStyle, BorderStyle.MEDIUM); cell.setCellStyle(cellStyle); sheet.autoSizeColumn(cellConfig.position); } }
@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.setColor(IndexedColors.BLACK.getIndex()); cellStyle.setFont(f); cellStyle.setDataFormat(df.getFormat("text")); }
@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.setColor(IndexedColors.BLACK.getIndex()); cellStyle.setFont(f); cellStyle.setDataFormat(df.getFormat("text")); }
public static XSSFCellStyle getHeadCellStyle(XSSFWorkbook wb, XSSFFont font) { XSSFCellStyle headCellStyle = wb.createCellStyle(); headCellStyle.setFont(font); headCellStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN); headCellStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN); headCellStyle.setBorderRight(HSSFCellStyle.BORDER_THIN); headCellStyle.setBorderTop(HSSFCellStyle.BORDER_THIN); headCellStyle.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index); headCellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); headCellStyle.setWrapText(false); headCellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER); headCellStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); return headCellStyle; }
private static XSSFCellStyle getHeadCellStyle(XSSFWorkbook wb, XSSFFont font) {//用到 XSSFCellStyle headCellStyle = wb.createCellStyle(); headCellStyle.setFont(font); headCellStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN); headCellStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN); headCellStyle.setBorderRight(HSSFCellStyle.BORDER_THIN); headCellStyle.setBorderTop(HSSFCellStyle.BORDER_THIN); headCellStyle.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index); headCellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND); headCellStyle.setWrapText(false); headCellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER); headCellStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); return headCellStyle; }
SerialWriteWorkbook() { this.swb = new SXSSFWorkbook(100); this.sh = this.swb.createSheet(); this.rowIndex = 0; this.headerStyle = (XSSFCellStyle)swb.createCellStyle(); this.headerStyle.setFillBackgroundColor(IndexedColors.BLACK.getIndex()); //solid fill this.headerStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); Font headerFont = swb.createFont(); headerFont.setFontHeightInPoints((short)14); headerFont.setBold(true); headerFont.setColor(IndexedColors.WHITE.getIndex()); this.headerStyle.setFont(headerFont); }
XSSFCellStyle styleSubHeader = (XSSFCellStyle) wb.createCellStyle(); styleSubHeader.setFont(fontBold); styleSubHeader.setVerticalAlignment(CellStyle.VERTICAL_CENTER); styleSubHeader.setAlignment(CellStyle.ALIGN_CENTER); styleSubHeader.setFillForegroundColor(COLOR_ORANGE); styleSubHeader.setFillPattern(CellStyle.SOLID_FOREGROUND); styleSubHeader.setBorderBottom(CellStyle.BORDER_THIN); styleSubHeader.setBottomBorderColor(COLOR_GREY); styleSubHeader.setBorderLeft(CellStyle.BORDER_THIN); styleSubHeader.setLeftBorderColor(COLOR_GREY); styleSubHeader.setBorderRight(CellStyle.BORDER_THIN); styleSubHeader.setRightBorderColor(COLOR_GREY); styleSubHeader.setBorderTop(CellStyle.BORDER_THIN); styleSubHeader.setTopBorderColor(COLOR_GREY);