List of usage examples for org.apache.poi.ss.usermodel CellStyle setFont
void setFont(Font font);
From source file:com.github.cutstock.excel.model.SheetBuilder.java
License:Apache License
private void initStyles() { CellStyle style; Workbook wb = sheet.getWorkbook();//from w w w . j a v a2s .c o m Font titleFont = wb.createFont(); titleFont.setFontHeightInPoints((short) 18); titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD); style = wb.createCellStyle(); style.setAlignment(CellStyle.ALIGN_CENTER); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); style.setFont(titleFont); styles.put("title", style); Font subTitle = wb.createFont(); subTitle.setFontHeightInPoints((short) 12); subTitle.setBoldweight(Font.BOLDWEIGHT_BOLD); style = wb.createCellStyle(); style.setAlignment(CellStyle.ALIGN_LEFT); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); style.setFont(subTitle); styles.put("header", style); style = wb.createCellStyle(); style.setAlignment(CellStyle.ALIGN_LEFT); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); style.setBorderRight(CellStyle.BORDER_THIN); style.setRightBorderColor(IndexedColors.BLACK.getIndex()); style.setBorderLeft(CellStyle.BORDER_THIN); style.setLeftBorderColor(IndexedColors.BLACK.getIndex()); style.setBorderTop(CellStyle.BORDER_THIN); style.setTopBorderColor(IndexedColors.BLACK.getIndex()); style.setBorderBottom(CellStyle.BORDER_THIN); style.setBottomBorderColor(IndexedColors.BLACK.getIndex()); styles.put("cell", style); style = wb.createCellStyle(); style.setAlignment(CellStyle.ALIGN_LEFT); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); style.setBorderRight(CellStyle.BORDER_THIN); style.setRightBorderColor(IndexedColors.BLACK.getIndex()); style.setBorderLeft(CellStyle.BORDER_THIN); style.setLeftBorderColor(IndexedColors.BLACK.getIndex()); style.setBorderTop(CellStyle.BORDER_THIN); style.setTopBorderColor(IndexedColors.BLACK.getIndex()); style.setBorderBottom(CellStyle.BORDER_THIN); style.setBottomBorderColor(IndexedColors.BLACK.getIndex()); styles.put("highCell", style); style = wb.createCellStyle(); Font imageTitle = wb.createFont(); imageTitle.setFontHeightInPoints((short) 200); style.setFont(imageTitle); styles.put("image", style); style = wb.createCellStyle(); style.setAlignment(CellStyle.ALIGN_CENTER); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); style.setFillForegroundColor(IndexedColors.GREY_40_PERCENT.getIndex()); style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setDataFormat(wb.createDataFormat().getFormat("0.00")); styles.put("formula_2", style); }
From source file:com.github.jferard.spreadsheetwrapper.xls.poi.XlsPoiStyleHelper.java
License:Open Source License
/** * @param workbook// w ww. j a v a 2s . c om * workbook for conversion * @param wrapperCellStyle * the cell style * @return the internal cell style */ public CellStyle toCellStyle(final Workbook workbook, final WrapperCellStyle wrapperCellStyle) { final CellStyle cellStyle = workbook.createCellStyle(); final Font font = this.fontHelper.toCellFont(workbook, wrapperCellStyle); cellStyle.setFont(font); final WrapperColor backgroundColor = wrapperCellStyle.getBackgroundColor(); if (backgroundColor != null) { final HSSFColor hssfColor = this.colorHelper.toHSSFColor(backgroundColor); final short index = hssfColor.getIndex(); cellStyle.setFillForegroundColor(index); cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND); } this.borderHelper.setCellBorders(wrapperCellStyle, cellStyle); return cellStyle; }
From source file:com.github.luischavez.lat.excel.Excel.java
License:Open Source License
protected void setContent(Workbook workbook, Sheet sheet, String groupName) { CellStyle style = workbook.createCellStyle(); Font font = workbook.createFont(); font.setColor(HSSFColor.WHITE.index); style.setFont(font); style.setFillBackgroundColor(IndexedColors.GREEN.getIndex()); style.setFillPattern(CellStyle.SOLID_FOREGROUND); Row row = sheet.createRow(0);//from w ww . j a v a 2 s . c om this.createCell(0, row, style, "#"); this.createCell(1, row, style, "Matricula"); this.createCell(2, row, style, "Nombres"); this.createCell(3, row, style, "Apellidos"); for (int i = 0; i < 6; i++) { this.createCell(4 + i, row, style, "Practica #" + (i + 1)); } this.createCell(10, row, style, "Promedio"); int current = 1; RowList students = this.studentController.getByGroup(groupName); long groupId = this.groupController.getGroupId(groupName); for (com.github.luischavez.database.link.Row student : students) { long studentId = student.value("student_id", Long.class); String credential = student.value("credential", String.class); String firstName = student.value("first_name", String.class); String lastName = student.value("last_name", String.class); row = sheet.createRow(current); this.createNumber(0, row, null, current++); this.createCell(1, row, null, credential); this.createCell(2, row, null, firstName); this.createCell(3, row, null, lastName); for (int i = 0; i < 6; i++) { double qualification = this.qualificationController.get(groupId, studentId, i + 1); if (0 > qualification) { qualification = 0; } this.createNumber(4 + i, row, null, qualification); } this.createFormula(10, row, style, String.format("AVERAGE(E%d:J%d)", current, current)); } row = sheet.createRow(current); this.createFormula(10, row, style, String.format("AVERAGE(K%d:K%d)", 2, current)); }
From source file:com.github.xiilei.ecdiff.Processor.java
License:Apache License
public boolean cellComparer(Cell src_cell, Cell dist_cell) { if (dist_cell == null) { logger.warn("comparer,dist_cell is null"); return false; }/*from w ww. j a va 2 s.c o m*/ if (src_cell == null || !getStringCellValue(dist_cell).trim().equals(getStringCellValue(src_cell))) { CellStyle style = dist_cell.getCellStyle(); style.setFont(this.font); dist_cell.setCellStyle(style); } return true; }
From source file:com.globalsight.everest.qachecks.DITAQAChecker.java
License:Apache License
private void addTitle(Workbook p_workBook, Sheet p_sheet) throws Exception { Font titleFont = p_workBook.createFont(); titleFont.setUnderline(Font.U_NONE); titleFont.setFontName("Times"); titleFont.setFontHeightInPoints((short) 14); titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD); CellStyle cs = p_workBook.createCellStyle(); cs.setFont(titleFont); Row titleRow = getRow(p_sheet, 0);//from w w w . j av a 2 s . c om Cell titleCell = getCell(titleRow, 0); titleCell.setCellValue("DITA QA Report"); titleCell.setCellStyle(cs); }
From source file:com.globalsight.everest.qachecks.DITAQAChecker.java
License:Apache License
private CellStyle getHeaderStyle(Workbook p_workbook) throws Exception { if (headerStyle == null) { Font font = p_workbook.createFont(); font.setBoldweight(Font.BOLDWEIGHT_BOLD); font.setColor(IndexedColors.BLACK.getIndex()); font.setUnderline(Font.U_NONE); font.setFontName("Times"); font.setFontHeightInPoints((short) 11); CellStyle cs = p_workbook.createCellStyle(); cs.setFont(font); cs.setWrapText(true);//from w ww. j a v a 2s . co m cs.setFillPattern(CellStyle.SOLID_FOREGROUND); cs.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); cs.setBorderTop(CellStyle.BORDER_THIN); cs.setBorderRight(CellStyle.BORDER_THIN); cs.setBorderBottom(CellStyle.BORDER_THIN); cs.setBorderLeft(CellStyle.BORDER_THIN); headerStyle = cs; } return headerStyle; }
From source file:com.globalsight.everest.qachecks.DITAQAChecker.java
License:Apache License
private CellStyle getContentStyle(Workbook p_workbook) throws Exception { if (contentStyle == null) { Font font = p_workbook.createFont(); font.setFontName("Arial"); font.setFontHeightInPoints((short) 10); CellStyle style = p_workbook.createCellStyle(); style.setFont(font); style.setWrapText(true);//from w w w. j a va 2s.c om style.setAlignment(CellStyle.ALIGN_LEFT); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); contentStyle = style; } return contentStyle; }
From source file:com.globalsight.everest.qachecks.DITAQAChecker.java
License:Apache License
private CellStyle getNoWrapContentStyle(Workbook p_workbook) throws Exception { if (noWrapContentStyle == null) { Font font = p_workbook.createFont(); font.setFontName("Arial"); font.setFontHeightInPoints((short) 10); CellStyle style = p_workbook.createCellStyle(); style.setFont(font); style.setWrapText(false);/*from w w w.j a va2 s .co m*/ style.setAlignment(CellStyle.ALIGN_LEFT); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); noWrapContentStyle = style; } return noWrapContentStyle; }
From source file:com.globalsight.everest.qachecks.DITAQAChecker.java
License:Apache License
private CellStyle getRtlContentStyle(Workbook p_workbook) throws Exception { if (rtlContentStyle == null) { Font font = p_workbook.createFont(); font.setFontName("Arial"); font.setFontHeightInPoints((short) 10); CellStyle style = p_workbook.createCellStyle(); style.setFont(font); style.setWrapText(true);/*from ww w. java 2s .c o m*/ style.setAlignment(CellStyle.ALIGN_RIGHT); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); rtlContentStyle = style; } return rtlContentStyle; }
From source file:com.globalsight.everest.qachecks.DITAQAChecker.java
License:Apache License
private CellStyle getUnlockedStyle(Workbook p_workbook) throws Exception { if (unlockedStyle == null) { Font font = p_workbook.createFont(); font.setFontName("Arial"); font.setFontHeightInPoints((short) 10); CellStyle style = p_workbook.createCellStyle(); style.setFont(font); style.setLocked(false);//www .ja v a 2 s .c o m style.setWrapText(true); style.setAlignment(CellStyle.ALIGN_LEFT); style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); unlockedStyle = style; } return unlockedStyle; }