List of usage examples for org.apache.poi.ss.usermodel HorizontalAlignment CENTER
HorizontalAlignment CENTER
To view the source code for org.apache.poi.ss.usermodel HorizontalAlignment CENTER.
Click Source Link
From source file:org.primefaces.extensions.showcase.util.ExcelCustomExporter.java
License:Apache License
protected void createCustomFonts() { Font facetFont = wb.createFont(); Font cellFont = wb.createFont(); if (cellFontColor != null) { XSSFColor cellColor = new XSSFColor(cellFontColor); ((XSSFFont) cellFont).setColor(cellColor); }/* w w w .j ava 2 s . co m*/ if (cellFontSize != null) { cellFont.setFontHeightInPoints(cellFontSize); } if (cellFontStyle.equalsIgnoreCase("BOLD")) { cellFont.setBold(true); } if (cellFontStyle.equalsIgnoreCase("ITALIC")) { cellFont.setItalic(true); } if (facetFontStyle.equalsIgnoreCase("BOLD")) { facetFont.setBold(true); } if (facetFontStyle.equalsIgnoreCase("ITALIC")) { facetFont.setItalic(true); } if (fontName != null) { cellFont.setFontName(fontName); facetFont.setFontName(fontName); } cellStyle.setFont(cellFont); if (facetBackground != null) { XSSFColor backgroundColor = new XSSFColor(facetBackground); ((XSSFCellStyle) facetStyle).setFillForegroundColor(backgroundColor); facetStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); } if (facetFontColor != null) { XSSFColor facetColor = new XSSFColor(facetFontColor); ((XSSFFont) facetFont).setColor(facetColor); } if (facetFontSize != null) { facetFont.setFontHeightInPoints(facetFontSize); } facetStyle.setFont(facetFont); facetStyle.setAlignment(HorizontalAlignment.CENTER); }
From source file:org.tsukuba_bunko.lilac.helper.port.impl.ExportAuthorHelperImpl.java
License:Open Source License
/** * @see org.tsukuba_bunko.lilac.helper.port.impl.ExportDataHelperBase#prepare(org.apache.poi.xssf.usermodel.XSSFWorkbook) *//*from ww w . j a va2s . c o m*/ @Override protected void prepare(XSSFWorkbook book) { flagCellStyle = book.createCellStyle(); flagCellStyle.setAlignment(HorizontalAlignment.CENTER); flagCellStyle.setVerticalAlignment(VerticalAlignment.CENTER); idCellStyle = book.createCellStyle(); commonCellStyle = book.createCellStyle(); commonCellStyle.setAlignment(HorizontalAlignment.LEFT); commonCellStyle.setVerticalAlignment(VerticalAlignment.TOP); noteCellStyle = book.createCellStyle(); XSSFFont noteFont = book.createFont(); noteFont.setFontHeightInPoints((short) 9); noteCellStyle.setFont(noteFont); noteCellStyle.setAlignment(HorizontalAlignment.LEFT); noteCellStyle.setVerticalAlignment(VerticalAlignment.TOP); noteCellStyle.setWrapText(true); }
From source file:org.tsukuba_bunko.lilac.helper.port.impl.ExportBibliographyHelperImpl.java
License:Open Source License
/** * @see org.tsukuba_bunko.lilac.helper.port.impl.ExportDataHelperBase#prepare(org.apache.poi.xssf.usermodel.XSSFWorkbook) *//*from w w w.j a v a 2s .c o m*/ @Override protected void prepare(XSSFWorkbook book) { flagCellStyle = book.createCellStyle(); flagCellStyle.setAlignment(HorizontalAlignment.CENTER); flagCellStyle.setVerticalAlignment(VerticalAlignment.CENTER); idCellStyle = book.createCellStyle(); commonCellStyle = book.createCellStyle(); commonCellStyle.setAlignment(HorizontalAlignment.LEFT); commonCellStyle.setVerticalAlignment(VerticalAlignment.TOP); authorsCellStyle = book.createCellStyle(); authorsCellStyle.setWrapText(true); authorsCellStyle.setAlignment(HorizontalAlignment.LEFT); authorsCellStyle.setVerticalAlignment(VerticalAlignment.TOP); dateCellStyle = book.createCellStyle(); dateCellStyle.setAlignment(HorizontalAlignment.LEFT); dateCellStyle.setVerticalAlignment(VerticalAlignment.TOP); }
From source file:org.tsukuba_bunko.lilac.helper.port.impl.ExportBookHelperImpl.java
License:Open Source License
/** * @see org.tsukuba_bunko.lilac.helper.port.impl.ExportDataHelperBase#prepare(org.apache.poi.xssf.usermodel.XSSFWorkbook) *//*from w w w. ja v a2s .c o m*/ @Override protected void prepare(XSSFWorkbook book) { flagCellStyle = book.createCellStyle(); flagCellStyle.setAlignment(HorizontalAlignment.CENTER); flagCellStyle.setVerticalAlignment(VerticalAlignment.CENTER); idCellStyle = book.createCellStyle(); XSSFFont idFont = book.createFont(); idFont.setFontHeightInPoints((short) 9); idCellStyle.setFont(idFont); commonCellStyle = book.createCellStyle(); commonCellStyle.setAlignment(HorizontalAlignment.LEFT); commonCellStyle.setVerticalAlignment(VerticalAlignment.TOP); dateCellStyle = book.createCellStyle(); dateCellStyle.setAlignment(HorizontalAlignment.LEFT); dateCellStyle.setVerticalAlignment(VerticalAlignment.TOP); }
From source file:org.tsukuba_bunko.lilac.helper.port.impl.ExportBookshelfHelperImpl.java
License:Open Source License
/** * @see org.tsukuba_bunko.lilac.helper.port.impl.ExportDataHelperBase#prepare(org.apache.poi.xssf.usermodel.XSSFWorkbook) *///from ww w . ja v a 2s.c o m @Override protected void prepare(XSSFWorkbook book) { flagCellStyle = book.createCellStyle(); flagCellStyle.setAlignment(HorizontalAlignment.CENTER); flagCellStyle.setVerticalAlignment(VerticalAlignment.CENTER); idCellStyle = book.createCellStyle(); noteCellStyle = book.createCellStyle(); XSSFFont noteFont = book.createFont(); noteFont.setFontHeightInPoints((short) 9); noteCellStyle.setFont(noteFont); noteCellStyle.setAlignment(HorizontalAlignment.LEFT); noteCellStyle.setVerticalAlignment(VerticalAlignment.TOP); noteCellStyle.setWrapText(true); }
From source file:org.tsukuba_bunko.lilac.helper.port.impl.ExportDataHelperBase.java
License:Open Source License
/** * @see org.tsukuba_bunko.lilac.helper.port.ExportDataHelper#exportData(org.apache.poi.xssf.usermodel.XSSFWorkbook) *//*from w w w.j a v a2 s.co m*/ @Override public void exportData(XSSFWorkbook book) { sheet = book.createSheet(getSheetName()); XSSFFont font = book.createFont(); font.setBold(true); font.setColor(IndexedColors.WHITE.index); headerCellStyle = book.createCellStyle(); headerCellStyle.setAlignment(HorizontalAlignment.CENTER); headerCellStyle.setVerticalAlignment(VerticalAlignment.CENTER); headerCellStyle .setFillForegroundColor(new XSSFColor(new byte[] { (byte) 256, (byte) 0, (byte) 112, (byte) 192 })); headerCellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); headerCellStyle.setFont(font); prepare(book); XSSFRow row = sheet.createRow(rowCount++); processHeaderRow(row); buildQuery().iterate(this); finish(book); }
From source file:org.tsukuba_bunko.lilac.helper.port.impl.ExportLabelHelperImpl.java
License:Open Source License
/** * @see org.tsukuba_bunko.lilac.helper.port.impl.ExportDataHelperBase#prepare(org.apache.poi.xssf.usermodel.XSSFWorkbook) *///from ww w . jav a 2s. com @Override protected void prepare(XSSFWorkbook book) { flagCellStyle = book.createCellStyle(); flagCellStyle.setAlignment(HorizontalAlignment.CENTER); flagCellStyle.setVerticalAlignment(VerticalAlignment.CENTER); noteCellStyle = book.createCellStyle(); XSSFFont noteFont = book.createFont(); noteFont.setFontHeightInPoints((short) 9); noteCellStyle.setFont(noteFont); noteCellStyle.setAlignment(HorizontalAlignment.LEFT); noteCellStyle.setVerticalAlignment(VerticalAlignment.TOP); noteCellStyle.setWrapText(true); }
From source file:org.unitime.timetable.export.XLSPrinter.java
License:Apache License
protected CellStyle getStyle(A f, boolean dashed, String format) { String styleId = (dashed ? "D" : "") + (f.has(F.BOLD) ? "b" : "") + (f.has(F.ITALIC) ? "i" : "") + (f.has(F.UNDERLINE) ? "u" : "") + (f.has(F.RIGHT) ? "R" : f.has(F.CENTER) ? "C" : "L") + (f.hasColor() ? "#" + Integer.toHexString(f.getColor().getRGB()) : "") + (format == null ? "" : "|" + format); CellStyle style = iStyles.get(styleId); if (style == null) { style = iWorkbook.createCellStyle(); if (dashed) { style.setBorderTop(BorderStyle.DASHED); style.setTopBorderColor(IndexedColors.BLACK.getIndex()); }//from ww w . ja v a 2s . c o m style.setAlignment(f.has(F.RIGHT) ? HorizontalAlignment.RIGHT : f.has(F.CENTER) ? HorizontalAlignment.CENTER : HorizontalAlignment.LEFT); style.setVerticalAlignment(VerticalAlignment.TOP); style.setFont(getFont(f.has(F.BOLD), f.has(F.ITALIC), f.has(F.UNDERLINE), f.getColor())); style.setWrapText(true); if (format != null) style.setDataFormat(iWorkbook.createDataFormat().getFormat(format)); iStyles.put(styleId, style); } return style; }
From source file:org.zafritech.zidingorms.io.excel.ExcelFunctions.java
private static Map<String, CellStyle> createStyles(Workbook wb) { Map<String, CellStyle> styles = new HashMap<String, CellStyle>(); CreationHelper creationHelper = wb.getCreationHelper(); CellStyle style;//from w w w. ja v a 2 s.c om // Header Font Font headerFont = wb.createFont(); headerFont.setFontHeightInPoints((short) 12); headerFont.setBold(true); headerFont.setColor(IndexedColors.WHITE.getIndex()); // Header Left Aligned Style style = createBorderedStyle(wb); style.setAlignment(HorizontalAlignment.LEFT); style.setVerticalAlignment(VerticalAlignment.CENTER); style.setFont(headerFont); style.setFillForegroundColor(IndexedColors.PALE_BLUE.getIndex()); style.setFillPattern(FillPatternType.SOLID_FOREGROUND); styles.put("HeaderLeftAlign", style); // Header Center Aligned Style style = createBorderedStyle(wb); style.setAlignment(HorizontalAlignment.CENTER); style.setVerticalAlignment(VerticalAlignment.CENTER); style.setFont(headerFont); style.setFillForegroundColor(IndexedColors.PALE_BLUE.getIndex()); style.setFillPattern(FillPatternType.SOLID_FOREGROUND); styles.put("HeaderCenterAlign", style); // Body Left Aligned Style style = createBorderedStyle(wb); style.setAlignment(HorizontalAlignment.LEFT); style.setVerticalAlignment(VerticalAlignment.TOP); styles.put("BodyLeftAlign", style); // Body Center Aligned Style style = createBorderedStyle(wb); style.setAlignment(HorizontalAlignment.CENTER); style.setVerticalAlignment(VerticalAlignment.TOP); styles.put("BodyCenterAlign", style); // Body Left Aligned WrapText Style style = createBorderedStyle(wb); style.setAlignment(HorizontalAlignment.LEFT); style.setVerticalAlignment(VerticalAlignment.TOP); style.setWrapText(true); styles.put("BodyLeftAlignWrapText", style); // Body Left Aligned Date Format Style style = createBorderedStyle(wb); style.setAlignment(HorizontalAlignment.LEFT); style.setVerticalAlignment(VerticalAlignment.TOP); style.setDataFormat(creationHelper.createDataFormat().getFormat("yyyy-MM-dd HH:mm:ss")); styles.put("BodyLeftAlignDate", style); // Body Center Aligned Date Format Style style = createBorderedStyle(wb); style.setAlignment(HorizontalAlignment.CENTER); style.setVerticalAlignment(VerticalAlignment.TOP); style.setDataFormat(creationHelper.createDataFormat().getFormat("yyyy-MM-dd HH:mm:ss")); styles.put("BodyCenterAlignDate", style); return styles; }
From source file:packtest.CalendarDemo.java
License:Apache License
/** * cell styles used for formatting calendar sheets *//*from w w w . j a va 2s .co m*/ private static Map<String, XSSFCellStyle> createStyles(XSSFWorkbook wb) { Map<String, XSSFCellStyle> styles = new HashMap<String, XSSFCellStyle>(); XSSFCellStyle style; XSSFFont titleFont = wb.createFont(); titleFont.setFontHeightInPoints((short) 48); titleFont.setColor(new XSSFColor(new java.awt.Color(39, 51, 89))); style = wb.createCellStyle(); style.setAlignment(HorizontalAlignment.CENTER); style.setVerticalAlignment(VerticalAlignment.CENTER); style.setFont(titleFont); styles.put("title", style); XSSFFont monthFont = wb.createFont(); monthFont.setFontHeightInPoints((short) 12); monthFont.setColor(new XSSFColor(new java.awt.Color(255, 255, 255))); monthFont.setBold(true); style = wb.createCellStyle(); style.setAlignment(HorizontalAlignment.CENTER); style.setVerticalAlignment(VerticalAlignment.CENTER); style.setFillForegroundColor(new XSSFColor(new java.awt.Color(39, 51, 89))); style.setFillPattern(FillPatternType.SOLID_FOREGROUND); style.setFont(monthFont); styles.put("month", style); XSSFFont dayFont = wb.createFont(); dayFont.setFontHeightInPoints((short) 14); dayFont.setBold(true); style = wb.createCellStyle(); style.setAlignment(HorizontalAlignment.LEFT); style.setVerticalAlignment(VerticalAlignment.TOP); style.setFillForegroundColor(new XSSFColor(new java.awt.Color(228, 232, 243))); style.setFillPattern(FillPatternType.SOLID_FOREGROUND); style.setBorderLeft(BorderStyle.THIN); style.setLeftBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89))); style.setBorderBottom(BorderStyle.THIN); style.setBottomBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89))); style.setFont(dayFont); styles.put("weekend_left", style); style = wb.createCellStyle(); style.setAlignment(HorizontalAlignment.CENTER); style.setVerticalAlignment(VerticalAlignment.TOP); style.setFillForegroundColor(new XSSFColor(new java.awt.Color(228, 232, 243))); style.setFillPattern(FillPatternType.SOLID_FOREGROUND); style.setBorderRight(BorderStyle.THIN); style.setRightBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89))); style.setBorderBottom(BorderStyle.THIN); style.setBottomBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89))); styles.put("weekend_right", style); style = wb.createCellStyle(); style.setAlignment(HorizontalAlignment.LEFT); style.setVerticalAlignment(VerticalAlignment.TOP); style.setBorderLeft(BorderStyle.THIN); style.setFillForegroundColor(new XSSFColor(new java.awt.Color(255, 255, 255))); style.setFillPattern(FillPatternType.SOLID_FOREGROUND); style.setLeftBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89))); style.setBorderBottom(BorderStyle.THIN); style.setBottomBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89))); style.setFont(dayFont); styles.put("workday_left", style); style = wb.createCellStyle(); style.setAlignment(HorizontalAlignment.CENTER); style.setVerticalAlignment(VerticalAlignment.TOP); style.setFillForegroundColor(new XSSFColor(new java.awt.Color(255, 255, 255))); style.setFillPattern(FillPatternType.SOLID_FOREGROUND); style.setBorderRight(BorderStyle.THIN); style.setRightBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89))); style.setBorderBottom(BorderStyle.THIN); style.setBottomBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89))); styles.put("workday_right", style); style = wb.createCellStyle(); style.setBorderLeft(BorderStyle.THIN); style.setFillForegroundColor(new XSSFColor(new java.awt.Color(234, 234, 234))); style.setFillPattern(FillPatternType.SOLID_FOREGROUND); style.setBorderBottom(BorderStyle.THIN); style.setBottomBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89))); styles.put("grey_left", style); style = wb.createCellStyle(); style.setFillForegroundColor(new XSSFColor(new java.awt.Color(234, 234, 234))); style.setFillPattern(FillPatternType.SOLID_FOREGROUND); style.setBorderRight(BorderStyle.THIN); style.setRightBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89))); style.setBorderBottom(BorderStyle.THIN); style.setBottomBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89))); styles.put("grey_right", style); return styles; }