当前位置: 首页>>代码示例>>Java>>正文


Java Font类代码示例

本文整理汇总了Java中org.apache.poi.ss.usermodel.Font的典型用法代码示例。如果您正苦于以下问题:Java Font类的具体用法?Java Font怎么用?Java Font使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Font类属于org.apache.poi.ss.usermodel包,在下文中一共展示了Font类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createIndentationCellStyle

import org.apache.poi.ss.usermodel.Font; //导入依赖的package包/类
public CellStyle createIndentationCellStyle(Workbook workbook, int s) {
	CellStyle dataStyle1 = this.createBorderCellStyle(workbook, true);
	Font dataFont = workbook.createFont();
	dataFont.setColor((short) 12);
	dataFont.setFontHeightInPoints((short) 10);
	dataStyle1.setFillPattern(FillPatternType.SOLID_FOREGROUND);
	dataStyle1.setFillForegroundColor((short) 11);
	dataStyle1.setFont(dataFont);
	dataStyle1.setVerticalAlignment(VerticalAlignment.CENTER);
	dataStyle1.setAlignment(HorizontalAlignment.LEFT);
	dataStyle1.setIndention(Short.valueOf(String.valueOf((s))));
	return dataStyle1;
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:14,代码来源:GridStyleBuilder.java

示例2: makeHeader

import org.apache.poi.ss.usermodel.Font; //导入依赖的package包/类
private void makeHeader ( final List<Field> columns, final HSSFSheet sheet )
{
    final Font font = sheet.getWorkbook ().createFont ();
    font.setFontName ( "Arial" );
    font.setBoldweight ( Font.BOLDWEIGHT_BOLD );
    font.setColor ( HSSFColor.WHITE.index );

    final CellStyle style = sheet.getWorkbook ().createCellStyle ();
    style.setFont ( font );
    style.setFillForegroundColor ( HSSFColor.BLACK.index );
    style.setFillPattern ( PatternFormatting.SOLID_FOREGROUND );

    final HSSFRow row = sheet.createRow ( 0 );

    for ( int i = 0; i < columns.size (); i++ )
    {
        final Field field = columns.get ( i );

        final HSSFCell cell = row.createCell ( i );
        cell.setCellValue ( field.getHeader () );
        cell.setCellStyle ( style );
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:24,代码来源:ExportEventsImpl.java

示例3: defaultHeaderCellStyle

import org.apache.poi.ss.usermodel.Font; //导入依赖的package包/类
/**
 * Returns the default header style. Obtained from:
 * http://svn.apache.org/repos/asf/poi
 * /trunk/src/examples/src/org/apache/poi/ss/examples/TimesheetDemo.java
 *
 * @param wb the wb
 * @return the cell style
 */
protected CellStyle defaultHeaderCellStyle(final Workbook wb) {
    CellStyle style;
    final Font monthFont = wb.createFont();
    monthFont.setFontHeightInPoints((short) 11);
    monthFont.setColor(IndexedColors.WHITE.getIndex());
    style = wb.createCellStyle();
    style.setAlignment(HorizontalAlignment.CENTER);
    style.setVerticalAlignment(VerticalAlignment.CENTER);
    style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
    style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
    style.setFont(monthFont);
    style.setWrapText(true);
    return style;
}
 
开发者ID:TFyre,项目名称:vaadin-gridexport,代码行数:23,代码来源:ExcelExport.java

示例4: doCreateCellStyle

import org.apache.poi.ss.usermodel.Font; //导入依赖的package包/类
/** 创建每个CellStyle,并放到map之中
 * @param workbook
 * @param styleInfo
 * @param dataFormat 
 * @return
 */
public static CellStyle doCreateCellStyle(Workbook workbook,ExportCellStyleInfo styleInfo,String dataFormat) {
	if(styleInfo != null ){
		CellStyle cellStyle = workbook.createCellStyle();
		setStyleValue(ExportCellStyleInfo.class, cellStyle, styleInfo);
		if(styleInfo.getFontStyleInfo() != null){
			Font fontStyle = workbook.createFont();
			setStyleValue(ExportFontStyleInfo.class, fontStyle, styleInfo.getFontStyleInfo());
			cellStyle.setFont(fontStyle);
		}
		if(!StringUtils.isEmpty(dataFormat)){
			short format = workbook.createDataFormat().getFormat(dataFormat);
			cellStyle.setDataFormat(format);
		}
		return cellStyle;
	}
	return null;
}
 
开发者ID:long47964,项目名称:excel-utils,代码行数:24,代码来源:CellStyleUtils.java

示例5: defaultTitleCellStyle

import org.apache.poi.ss.usermodel.Font; //导入依赖的package包/类
/**
 * Returns the default title style. Obtained from:
 * http://svn.apache.org/repos/asf/poi
 * /trunk/src/examples/src/org/apache/poi/ss/examples/TimesheetDemo.java
 *
 * @param wb the wb
 * @return the cell style
 */
protected CellStyle defaultTitleCellStyle(final Workbook wb) {
    CellStyle style;
    final Font titleFont = wb.createFont();
    titleFont.setFontHeightInPoints((short) 18);
    titleFont.setBold(true);
    style = wb.createCellStyle();
    style.setAlignment(HorizontalAlignment.CENTER);
    style.setVerticalAlignment(VerticalAlignment.CENTER);
    style.setFont(titleFont);
    return style;
}
 
开发者ID:TFyre,项目名称:vaadin-gridexport,代码行数:20,代码来源:ExcelExport.java

示例6: setCellStyleFont

import org.apache.poi.ss.usermodel.Font; //导入依赖的package包/类
public void setCellStyleFont(Workbook workbook, CellStyle style, int i) {
	Font font = workbook.createFont();
	if (i == 0) {
		// 正常
	} else if (i == 4) {
		// 下划线
		font.setUnderline(Font.U_SINGLE);
		style.setFont(font);
	} else if (i == 2) {
		// 倾斜
		font.setItalic(true);
		style.setFont(font);
	} else if (i == 1) {
		// 加粗
		font.setBold(true);
		style.setFont(font);
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:19,代码来源:AbstractStyleBuilder.java

示例7: createStyles

import org.apache.poi.ss.usermodel.Font; //导入依赖的package包/类
/**
     * 创建表格样式
     * @param wb 工作薄对象
     * @return 样式列表
     */
    private Map<String, CellStyle> createStyles(Workbook wb) {
        Map<String, CellStyle> styles = new HashMap<String, CellStyle>();

        CellStyle style = wb.createCellStyle();
        style.setAlignment(CellStyle.ALIGN_CENTER);
        style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
        Font titleFont = wb.createFont();
        titleFont.setFontName("Arial");
        titleFont.setFontHeightInPoints((short) 16);
        titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
        style.setFont(titleFont);
        styles.put("title", style);

        style = wb.createCellStyle();
        style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
        style.setBorderRight(CellStyle.BORDER_THIN);
        style.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
        style.setBorderLeft(CellStyle.BORDER_THIN);
        style.setLeftBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
        style.setBorderTop(CellStyle.BORDER_THIN);
        style.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
        style.setBorderBottom(CellStyle.BORDER_THIN);
        style.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
        Font dataFont = wb.createFont();
        dataFont.setFontName("Arial");
        dataFont.setFontHeightInPoints((short) 10);
        style.setFont(dataFont);
        styles.put("data", style);

        style = wb.createCellStyle();
        style.cloneStyleFrom(styles.get("data"));
        style.setAlignment(CellStyle.ALIGN_LEFT);
        styles.put("data1", style);

        style = wb.createCellStyle();
        style.cloneStyleFrom(styles.get("data"));
        style.setAlignment(CellStyle.ALIGN_CENTER);
        styles.put("data2", style);

        style = wb.createCellStyle();
        style.cloneStyleFrom(styles.get("data"));
        style.setAlignment(CellStyle.ALIGN_RIGHT);
        styles.put("data3", style);

        style = wb.createCellStyle();
        style.cloneStyleFrom(styles.get("data"));
//		style.setWrapText(true);
        style.setAlignment(CellStyle.ALIGN_CENTER);
        style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
        style.setFillPattern(CellStyle.SOLID_FOREGROUND);
        Font headerFont = wb.createFont();
        headerFont.setFontName("Arial");
        headerFont.setFontHeightInPoints((short) 10);
        headerFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
        headerFont.setColor(IndexedColors.WHITE.getIndex());
        style.setFont(headerFont);
        styles.put("header", style);

        return styles;
    }
 
开发者ID:sombie007,项目名称:ExcelHandle,代码行数:66,代码来源:ExportExcel.java

示例8: getCellStyle

import org.apache.poi.ss.usermodel.Font; //导入依赖的package包/类
/**
 * Fixed all properties suitable for cell-related style.
 * 
 * @param workbook Excel Workbook
 * @param boardStyle all properties suitable on the style of a cell
 * @param font a font
 * @return the customized style
 */
protected static CellStyle getCellStyle(Workbook workbook, TableStyle boardStyle, Font font) {
  XSSFCellStyle cellStyle = (XSSFCellStyle) workbook.createCellStyle();
  if (boardStyle.getFillColor() != null) {
    cellStyle.setFillForegroundColor(boardStyle.getFillColor());
    cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
  }
  cellStyle.setBorderLeft(boardStyle.getCellBorderLeft());
  cellStyle.setBorderRight(boardStyle.getCellBorderRight());
  cellStyle.setBorderTop(boardStyle.getCellBorderTop());
  cellStyle.setBorderBottom(boardStyle.getCellBorderBottom());
  cellStyle.setAlignment(boardStyle.getAlignment());

  cellStyle.setBorderColor(BorderSide.LEFT, boardStyle.getBorderColor());
  cellStyle.setBorderColor(BorderSide.RIGHT, boardStyle.getBorderColor());
  cellStyle.setBorderColor(BorderSide.TOP, boardStyle.getBorderColor());
  cellStyle.setBorderColor(BorderSide.BOTTOM, boardStyle.getBorderColor());

  if (font != null) {
    cellStyle.setFont(font);
  }
  return cellStyle;
}
 
开发者ID:lynchmaniac,项目名称:poilight,代码行数:31,代码来源:PoiLightStyle.java

示例9: createHeadStyle

import org.apache.poi.ss.usermodel.Font; //导入依赖的package包/类
CellStyle createHeadStyle() {
	if (headerCellStyle != null) {
		return headerCellStyle;
	}
	CellStyle style = wb.createCellStyle();
	// 设置这些样式
	style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.index);
	style.setFillPattern(CellStyle.SOLID_FOREGROUND);

	style.setAlignment(CellStyle.ALIGN_CENTER);
	// 生成一个字体
	Font font = wb.createFont();
	font.setColor(IndexedColors.BLACK.index);
	font.setFontHeightInPoints((short) 12);
	font.setBoldweight(Font.BOLDWEIGHT_BOLD);
	// 把字体应用到当前的样式
	style.setFont(font);
	headerCellStyle = style;
	return style;
}
 
开发者ID:bingyulei007,项目名称:bingexcel,代码行数:21,代码来源:AbstractWriteHandler.java

示例10: createHeadDateStyle

import org.apache.poi.ss.usermodel.Font; //导入依赖的package包/类
CellStyle createHeadDateStyle() {
	if (headDateCellStyle != null) {
		return headDateCellStyle;
	}
	CellStyle cellStyle = wb.createCellStyle();
	DataFormat format = wb.createDataFormat();
	cellStyle.setDataFormat(format.getFormat("m/d/yy h:mm"));

	// 设置这些样式
	cellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.index);
	cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);

	cellStyle.setAlignment(CellStyle.ALIGN_CENTER);
	// 生成一个字体
	Font font = wb.createFont();
	font.setColor(IndexedColors.BLACK.index);
	font.setFontHeightInPoints((short) 12);
	font.setBoldweight(Font.BOLDWEIGHT_BOLD);
	// 把字体应用到当前的样式
	cellStyle.setFont(font);

	headDateCellStyle = cellStyle;
	return cellStyle;
}
 
开发者ID:bingyulei007,项目名称:bingexcel,代码行数:25,代码来源:AbstractWriteHandler.java

示例11: initFonts

import org.apache.poi.ss.usermodel.Font; //导入依赖的package包/类
/**
 * Initialisation des polices
 */
protected void initFonts() {
	Font fontHeader = workbook.createFont();
	fontHeader.setFontHeightInPoints(getHeaderFontHeight());
	fontHeader.setFontName(getFontName());
	fontHeader.setBoldweight(Font.BOLDWEIGHT_BOLD);
	setFontColor(fontHeader, colorRegistry, HEADER_FONT_COLOR_INDEX);
	registerFont(FONT_HEADER_NAME, fontHeader);

	Font fontNormal = workbook.createFont();
	fontNormal.setFontHeightInPoints(getNormalFontHeight());
	fontNormal.setFontName(getFontName());
	registerFont(FONT_NORMAL_NAME, fontNormal);
	
	Font fontLink = workbook.createFont();
	fontLink.setFontHeightInPoints(getNormalFontHeight());
	fontLink.setFontName(getFontName());
	fontLink.setUnderline(Font.U_SINGLE);
	setFontColor(fontLink, colorRegistry, LINK_FONT_COLOR_INDEX);
	registerFont(FONT_LINK_NAME, fontLink);
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:24,代码来源:AbstractExcelTableExport.java

示例12: createLinkStyle

import org.apache.poi.ss.usermodel.Font; //导入依赖的package包/类
private CellStyle createLinkStyle(boolean bordered) {
	final Font hlinkFont = wb.createFont();
	hlinkFont.setUnderline(Font.U_SINGLE);
	hlinkFont.setColor(IndexedColors.BLUE.getIndex());
	
	final CellStyle style;
	if (bordered) {
		style = createBorderedStyle(wb);
	} else {
		style = wb.createCellStyle();
	}
	
	style.setFont(hlinkFont);
	style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
	style.setIndention((short) 1);
	style.setWrapText(true);
	
	return style;
}
 
开发者ID:sigmah-dev,项目名称:sigmah,代码行数:20,代码来源:ExcelUtils.java

示例13: initFont

import org.apache.poi.ss.usermodel.Font; //导入依赖的package包/类
/**
 * 初始化字体样式
 *
 * @param font
 * @param fontBean
 */
private void initFont(Font font, FontStyleBean fontBean) {
    font.setFontName(fontBean.getName());
    font.setFontHeightInPoints(fontBean.getSize());

    if (fontBean.getBoldWeight() != null) {
        font.setBoldweight(fontBean.getBoldWeight());
    }

    if (fontBean.getItalic() != null) {
        font.setItalic(fontBean.getItalic());
    }

    if (fontBean.getUnderLine() != null) {
        font.setUnderline(fontBean.getUnderLine());
    }

    if (fontBean.getColor() != null) {
        ColorBean cbean = fontBean.getColor();

        ((XSSFFont) font).setColor(new XSSFColor(new Color(cbean.getR(), cbean.getG(), cbean.getB())));
    }

}
 
开发者ID:cgfalcon,项目名称:fluentexcel,代码行数:30,代码来源:XlsxRender.java

示例14: openOutputData

import org.apache.poi.ss.usermodel.Font; //导入依赖的package包/类
/**
 * @throws TechnicalException
 *             is thrown if you have a technical error (format, configuration, datas, ...) in NoraUi.
 */
void openOutputData() throws TechnicalException {
    this.dataOutExtension = validExtension(dataOutPath);
    try (FileInputStream fileOut = new FileInputStream(dataOutPath + scenarioName + "." + dataOutExtension);) {
        initWorkbook(fileOut, dataOutExtension);
    } catch (final IOException e) {
        throw new TechnicalException(Messages.getMessage(TechnicalException.TECHNICAL_ERROR_MESSAGE_DATA_IOEXCEPTION), e);
    }

    styleSuccess = workbook.createCellStyle();
    final Font fontSuccess = workbook.createFont();
    fontSuccess.setColor(HSSFColor.HSSFColorPredefined.GREEN.getIndex());
    styleSuccess.setFont(fontSuccess);

    styleFailed = workbook.createCellStyle();
    final Font fontFailed = workbook.createFont();
    fontFailed.setColor(HSSFColor.HSSFColorPredefined.RED.getIndex());
    styleFailed.setFont(fontFailed);

    styleWarning = workbook.createCellStyle();
    final Font fontWarning = workbook.createFont();
    fontWarning.setColor(HSSFColor.HSSFColorPredefined.ORANGE.getIndex());
    styleWarning.setFont(fontWarning);
}
 
开发者ID:NoraUi,项目名称:NoraUi,代码行数:28,代码来源:ExcelDataProvider.java

示例15: createStyles

import org.apache.poi.ss.usermodel.Font; //导入依赖的package包/类
/**
 * excel 样式
 *
 * @return
 */
public Map<String, CellStyle> createStyles(Workbook workbook) {
    Map<String, CellStyle> styles = new HashMap();
    CellStyle style = workbook.createCellStyle();
    style.setAlignment((short) 2);
    style.setVerticalAlignment((short) 1);
    Font titleFont = workbook.createFont();
    titleFont.setFontName("Arial");
    titleFont.setFontHeightInPoints((short) 16);
    titleFont.setBoldweight((short) 700);
    style.setFont(titleFont);
    styles.put("title", style);
    style = workbook.createCellStyle();
    style.setVerticalAlignment((short) 1);
    style.setBorderRight((short) 1);
    style.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
    style.setBorderLeft((short) 1);
    style.setLeftBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
    style.setBorderTop((short) 1);
    style.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
    style.setBorderBottom((short) 1);
    style.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
    Font dataFont = workbook.createFont();
    dataFont.setFontName("Arial");
    dataFont.setFontHeightInPoints((short) 10);
    style.setFont(dataFont);
    styles.put("data", style);
    style = workbook.createCellStyle();
    style.cloneStyleFrom((CellStyle) styles.get("data"));
    style.setAlignment((short) 1);
    styles.put("data1", style);
    style = workbook.createCellStyle();
    style.cloneStyleFrom((CellStyle) styles.get("data"));
    style.setAlignment((short) 2);
    styles.put("data2", style);
    style = workbook.createCellStyle();
    style.cloneStyleFrom((CellStyle) styles.get("data"));
    style.setAlignment((short) 3);
    styles.put("data3", style);
    style = workbook.createCellStyle();
    style.cloneStyleFrom((CellStyle) styles.get("data"));
    style.setAlignment((short) 2);
    style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
    style.setFillPattern((short) 1);
    Font headerFont = workbook.createFont();
    headerFont.setFontName("Arial");
    headerFont.setFontHeightInPoints((short) 10);
    headerFont.setBoldweight((short) 700);
    headerFont.setColor(IndexedColors.WHITE.getIndex());
    style.setFont(headerFont);
    styles.put("header", style);
    return styles;
}
 
开发者ID:zhangbiy,项目名称:exportExcel,代码行数:58,代码来源:ExcelTest.java


注:本文中的org.apache.poi.ss.usermodel.Font类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。