List of usage examples for org.apache.poi.xssf.usermodel XSSFFont setItalic
public void setItalic(boolean italic)
From source file:ch.admin.isb.hermes5.business.userszenario.projektstrukturplan.ProjektstrukturplanGeneratorExcel.java
License:Apache License
private XSSFCellStyle getErgebnisStyle(XSSFWorkbook wb) { XSSFCellStyle cellStyle = wb.createCellStyle(); XSSFFont font = wb.createFont(); font.setItalic(true); font.setFontHeight(10);/*from ww w. jav a 2 s . c om*/ font.setFontName(fontName.getStringValue()); cellStyle.setFont(font); return cellStyle; }
From source file:com.hauldata.dbpa.file.book.XlsxTargetSheet.java
License:Apache License
private static Font getFont(FontStyles fontStyles, SXSSFWorkbook book, Map<FontStyles, XSSFFont> fontsUsed, Map<Integer, XSSFColor> colorsUsed) { XSSFFont font = fontsUsed.get(fontStyles); if (font != null) { return font; }/* w ww . ja v a 2 s . c o m*/ font = (XSSFFont) book.createFont(); if (fontStyles.color != null) { font.setColor(getColor(fontStyles.color, book, colorsUsed)); } if (fontStyles.fontStyle != null) { switch (fontStyles.fontStyle) { case NORMAL: break; case ITALIC: font.setItalic(true); break; } } if (fontStyles.fontWeight != null) { switch (fontStyles.fontWeight) { case NORMAL: break; case BOLD: font.setBold(true); break; } } if (fontStyles.textDecorationLine != null) { switch (fontStyles.textDecorationLine) { case NONE: break; case LINE_THROUGH: font.setStrikeout(true); break; case UNDERLINE: font.setUnderline((fontStyles.textDecorationStyle == FontStyles.TextDecorationStyle.DOUBLE) ? FontUnderline.DOUBLE : FontUnderline.SINGLE); break; } } fontsUsed.put(fontStyles, font); return font; }
From source file:document.ExcelDocumentStyles.java
private void fontItalic(XSSFFont font) { font.setItalic(true); }
From source file:net.mcnewfamily.rmcnew.model.excel.FontEssence.java
License:Open Source License
public XSSFFont toXSSFFont(XSSFWorkbook workbook) { XSSFFont xssfFont = null; if (workbook != null) { xssfFont = workbook.createFont(); xssfFont.setCharSet(FontCharset.DEFAULT); xssfFont.setFamily(this.fontFamily); xssfFont.setBold(this.bold); if (this.bold) { xssfFont.setBoldweight(Font.BOLDWEIGHT_BOLD); } else {//from w ww . j av a 2 s.c o m xssfFont.setBoldweight(Font.BOLDWEIGHT_NORMAL); } xssfFont.setItalic(this.italic); if (this.underline) { xssfFont.setUnderline(FontUnderline.SINGLE); } xssfFont.setStrikeout(this.strikeout); xssfFont.setColor(this.color); xssfFont.setFontHeightInPoints(this.fontHeightInPoints); } else { throw new IllegalArgumentException("Cannot create XSSFFont in a null XSSFWorkbook!"); } return xssfFont; }
From source file:org.agmip.ui.afsirs.util.SummaryReportExcelFormat.java
private XSSFCellStyle getCellStyle(int type) { XSSFFont font = workbook.createFont(); XSSFCellStyle style = null;/*www .j a va 2 s . co m*/ switch (type) { case 1: font.setFontHeightInPoints((short) 15); font.setFontName("IMPACT"); font.setItalic(true); font.setColor(HSSFColor.BLUE.index); style = workbook.createCellStyle(); style.setWrapText(true); style.setVerticalAlignment(VerticalAlignment.CENTER); style.setAlignment(HorizontalAlignment.CENTER); style.setFont(font); break; case 2: font.setFontHeightInPoints((short) 15); font.setFontName("IMPACT"); font.setItalic(true); font.setColor(HSSFColor.BLUE.index); style = workbook.createCellStyle(); style.setWrapText(true); style.setShrinkToFit(true); style.setFont(font); break; case 3: font.setFontHeightInPoints((short) 15); font.setFontName("IMPACT"); font.setItalic(true); font.setColor(HSSFColor.BLUE.index); style = workbook.createCellStyle(); style.setWrapText(true); style.setShrinkToFit(true); style.setFont(font); break; case 4: font.setFontHeightInPoints((short) 15); font.setFontName("IMPACT"); font.setItalic(true); font.setColor(HSSFColor.BLUE.index); style = workbook.createCellStyle(); style.setWrapText(true); style.setVerticalAlignment(VerticalAlignment.CENTER); style.setAlignment(HorizontalAlignment.CENTER); style.setFont(font); break; case 5: font.setFontHeightInPoints((short) 15); font.setFontName("IMPACT"); font.setItalic(true); font.setColor(HSSFColor.BLUE.index); style = workbook.createCellStyle(); style.setWrapText(true); style.setVerticalAlignment(VerticalAlignment.CENTER); style.setAlignment(HorizontalAlignment.CENTER); style.setFont(font); break; } return style; }
From source file:org.azkfw.document.database.xlsx.XLSXWriter.java
License:Apache License
private XSSFWorkbook write(final DatabaseModel datasource) { workbook = new XSSFWorkbook(); styleManager = new CellStyleManager(workbook); // ?/*from ww w . jav a 2s . c om*/ fontTitle = workbook.createFont(); fontTitle.setBold(true); fontTitle.setItalic(true); fontTitle.setFontHeightInPoints((short) 12); fontLabel = workbook.createFont(); fontLabel.setBold(true); fontLabel.setFontHeightInPoints((short) 9); fontValue = workbook.createFont(); fontValue.setBold(false); fontValue.setFontHeightInPoints((short) 9); fontLink = workbook.createFont(); fontLink.setUnderline(Font.U_SINGLE); fontLink.setColor(IndexedColors.BLUE.getIndex()); fontLink.setFontHeightInPoints((short) 9); styleTitle = workbook.createCellStyle(); styleTitle.setFont(fontTitle); ///////////////////////////////////////////////////////////////////// XSSFFont fontPK = workbook.createFont(); fontPK.setBold(true); fontPK.setItalic(true); fontPK.setFontHeightInPoints((short) 9); // Value defStyleHeadValue = workbook.createCellStyle(); defStyleHeadValue.setFillPattern(CellStyle.SOLID_FOREGROUND); defStyleHeadValue.setFillForegroundColor(IndexedColors.WHITE.getIndex()); defStyleHeadValue.setFont(fontValue); defStyleHeadValue.setBorderTop(CellStyle.BORDER_THIN); defStyleHeadValue.setBorderBottom(CellStyle.BORDER_THIN); defStyleHeadValue.setBorderLeft(CellStyle.BORDER_THIN); defStyleHeadValue.setBorderRight(CellStyle.BORDER_THIN); styleManager.set(defStyleHeadValue); defStyleLabel = workbook.createCellStyle(); defStyleLabel.setFillPattern(CellStyle.SOLID_FOREGROUND); defStyleLabel.setFillForegroundColor(IndexedColors.LIGHT_GREEN.getIndex()); defStyleLabel.setFont(fontLabel); defStyleLabel.setBorderTop(CellStyle.BORDER_THIN); defStyleLabel.setBorderBottom(CellStyle.BORDER_THIN); defStyleLabel.setBorderLeft(CellStyle.BORDER_THIN); defStyleLabel.setBorderRight(CellStyle.BORDER_THIN); styleManager.set(defStyleLabel); // defStyleListValue = workbook.createCellStyle(); defStyleListValue.setFillPattern(CellStyle.SOLID_FOREGROUND); defStyleListValue.setFillForegroundColor(IndexedColors.WHITE.getIndex()); defStyleListValue.setFont(fontValue); defStyleListValue.setBorderTop(CellStyle.BORDER_DOTTED); defStyleListValue.setBorderBottom(CellStyle.BORDER_DOTTED); defStyleListValue.setBorderLeft(CellStyle.BORDER_THIN); defStyleListValue.setBorderRight(CellStyle.BORDER_THIN); styleManager.set(defStyleListValue); // defStyleListValueNo = workbook.createCellStyle(); defStyleListValueNo.setAlignment(CellStyle.ALIGN_RIGHT); defStyleListValueNo.setFillPattern(CellStyle.SOLID_FOREGROUND); defStyleListValueNo.setFillForegroundColor(IndexedColors.WHITE.getIndex()); defStyleListValueNo.setFont(fontValue); defStyleListValueNo.setBorderTop(CellStyle.BORDER_DOTTED); defStyleListValueNo.setBorderBottom(CellStyle.BORDER_DOTTED); defStyleListValueNo.setBorderLeft(BD_RECT); defStyleListValueNo.setBorderRight(CellStyle.BORDER_THIN); styleManager.set(defStyleListValueNo); // Value(pk) defStyleListValuePK = workbook.createCellStyle(); defStyleListValuePK.setFillPattern(CellStyle.SOLID_FOREGROUND); defStyleListValuePK.setFillForegroundColor(IndexedColors.WHITE.getIndex()); defStyleListValuePK.setFont(fontPK); defStyleListValuePK.setBorderTop(CellStyle.BORDER_DOTTED); defStyleListValuePK.setBorderBottom(CellStyle.BORDER_DOTTED); defStyleListValuePK.setBorderLeft(CellStyle.BORDER_THIN); defStyleListValuePK.setBorderRight(CellStyle.BORDER_THIN); styleManager.set(defStyleListValuePK); // Value(center) defStyleListValueCenter = workbook.createCellStyle(); defStyleListValueCenter.setFillPattern(CellStyle.SOLID_FOREGROUND); defStyleListValueCenter.setFillForegroundColor(IndexedColors.WHITE.getIndex()); defStyleListValueCenter.setFont(fontValue); defStyleListValueCenter.setAlignment(CellStyle.ALIGN_CENTER); defStyleListValueCenter.setBorderTop(CellStyle.BORDER_DOTTED); defStyleListValueCenter.setBorderBottom(CellStyle.BORDER_DOTTED); defStyleListValueCenter.setBorderLeft(CellStyle.BORDER_THIN); defStyleListValueCenter.setBorderRight(CellStyle.BORDER_THIN); styleManager.set(defStyleListValueCenter); // Value(link) defStyleListValueLink = workbook.createCellStyle(); defStyleListValueLink.setFillPattern(CellStyle.SOLID_FOREGROUND); defStyleListValueLink.setFillForegroundColor(IndexedColors.WHITE.getIndex()); defStyleListValueLink.setFont(fontLink); defStyleListValueLink.setBorderTop(CellStyle.BORDER_DOTTED); defStyleListValueLink.setBorderBottom(CellStyle.BORDER_DOTTED); defStyleListValueLink.setBorderLeft(CellStyle.BORDER_THIN); defStyleListValueLink.setBorderRight(CellStyle.BORDER_THIN); styleManager.set(defStyleListValueLink); // ? workbook.createSheet(getTableListSheetName()); for (TableModel table : datasource.getTables()) { workbook.createSheet(getTableSheetName(table.getName())); } // createTableListSheet(datasource, workbook.getSheet(getTableListSheetName())); // for (TableModel table : datasource.getTables()) { XSSFSheet sheet = workbook.getSheet(getTableSheetName(table.getName())); createTableSheet(datasource, table, sheet); } return workbook; }
From source file:org.displaytag.render.XssfTableWriter.java
License:Artistic License
/** * @see org.displaytag.render.TableWriterTemplate#writeCaption(org.displaytag.model.TableModel) *///from ww w . j a v a 2 s .c o m protected void writeCaption(TableModel model) throws Exception { XSSFFont captionFont = wb.createFont(); captionFont.setFontHeightInPoints((short) 14); captionFont.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); captionFont.setBold(true); captionFont.setItalic(false); CellStyle captionstyle = this.wb.createCellStyle(); captionstyle.setAlignment(CellStyle.ALIGN_CENTER); captionstyle.setFont(captionFont); this.colNum = 0; this.currentRow = this.sheet.createRow(this.rowNum++); this.currentCell = this.currentRow.createCell(this.colNum++); this.currentCell.setCellStyle(captionstyle); String caption = model.getCaption(); this.currentCell.setCellValue(new XSSFRichTextString(caption)); this.rowSpanTable(model); }
From source file:org.displaytag.render.XssfTableWriter.java
License:Artistic License
/** * Obtain the style used to render a header or footer. * @return The style used to render a header or footer. *///from w ww . j av a 2 s . co m private XSSFCellStyle getHeaderFooterStyle() { XSSFFont font = this.wb.createFont(); font.setColor(IndexedColors.WHITE.getIndex()); font.setBold(true); font.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); font.setItalic(false); XSSFCellStyle style = this.wb.createCellStyle(); style.setFillPattern(XSSFCellStyle.FINE_DOTS); style.setFillBackgroundColor(IndexedColors.BLUE_GREY.getIndex()); style.setFont(font); return style; }
From source file:org.jkiss.dbeaver.data.office.export.DataExporterXLSX.java
License:Apache License
@Override public void init(IStreamDataExporterSite site) throws DBException { Object nullStringProp = site.getProperties().get(PROP_NULL_STRING); nullString = nullStringProp == null ? null : nullStringProp.toString(); try {//from w ww.ja v a 2 s.c om printHeader = (Boolean) site.getProperties().get(PROP_HEADER); } catch (Exception e) { printHeader = false; } try { rowNumber = (Boolean) site.getProperties().get(PROP_ROWNUMBER); } catch (Exception e) { rowNumber = false; } try { boolTrue = (String) site.getProperties().get(PROP_TRUESTRING); } catch (Exception e) { boolTrue = "true"; } try { boolFalse = (String) site.getProperties().get(PROP_FALSESTRING); } catch (Exception e) { boolFalse = "false"; } if (!"true".equals(boolTrue) || !"false".equals(boolFalse)) { booleRedefined = true; } try { exportSql = (Boolean) site.getProperties().get(PROP_EXPORT_SQL); } catch (Exception e) { exportSql = false; } try { splitSqlText = (Boolean) site.getProperties().get(PROP_SPLIT_SQLTEXT); } catch (Exception e) { splitSqlText = false; } try { splitByRowCount = (Integer) site.getProperties().get(PROP_SPLIT_BYROWCOUNT); } catch (Exception e) { splitByRowCount = EXCEL2007MAXROWS; } try { splitByCol = (Integer) site.getProperties().get(PROP_SPLIT_BYCOL); } catch (Exception e) { splitByCol = -1; } wb = new SXSSFWorkbook(ROW_WINDOW); worksheets = new HashMap<>(1); styleHeader = (XSSFCellStyle) wb.createCellStyle(); BorderStyle border; try { border = BorderStyle.valueOf((String) site.getProperties().get(PROP_BORDER)); } catch (Exception e) { border = BorderStyle.NONE; } FontStyleProp fontStyle; try { fontStyle = FontStyleProp.valueOf((String) site.getProperties().get(PROP_HEADER_FONT)); } catch (Exception e) { fontStyle = FontStyleProp.NONE; } styleHeader.setBorderTop(border); styleHeader.setBorderBottom(border); styleHeader.setBorderLeft(border); styleHeader.setBorderRight(border); XSSFFont fontBold = (XSSFFont) wb.createFont(); switch (fontStyle) { case BOLD: fontBold.setBold(true); break; case ITALIC: fontBold.setItalic(true); break; case STRIKEOUT: fontBold.setStrikeout(true); break; case UNDERLINE: fontBold.setUnderline((byte) 3); break; default: break; } styleHeader.setFont(fontBold); style = (XSSFCellStyle) wb.createCellStyle(); style.setBorderTop(border); style.setBorderBottom(border); style.setBorderLeft(border); style.setBorderRight(border); this.rowCount = 0; super.init(site); }
From source file:packtest.WorkingWithRichText.java
License:Apache License
public static void main(String[] args) throws Exception { XSSFWorkbook wb = new XSSFWorkbook(); //or new HSSFWorkbook(); try {//from w w w. j a v a2 s .c o m XSSFSheet sheet = wb.createSheet(); XSSFRow row = sheet.createRow((short) 2); XSSFCell cell = row.createCell(1); XSSFRichTextString rt = new XSSFRichTextString("The quick brown fox"); XSSFFont font1 = wb.createFont(); font1.setBold(true); font1.setColor(new XSSFColor(new java.awt.Color(255, 0, 0))); rt.applyFont(0, 10, font1); XSSFFont font2 = wb.createFont(); font2.setItalic(true); font2.setUnderline(XSSFFont.U_DOUBLE); font2.setColor(new XSSFColor(new java.awt.Color(0, 255, 0))); rt.applyFont(10, 19, font2); XSSFFont font3 = wb.createFont(); font3.setColor(new XSSFColor(new java.awt.Color(0, 0, 255))); rt.append(" Jumped over the lazy dog", font3); cell.setCellValue(rt); // Write the output to a file OutputStream fileOut = new FileOutputStream(Utils.getPath("xssf-richtext.xlsx")); try { wb.write(fileOut); } finally { fileOut.close(); } } finally { wb.close(); } }