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


Java Font.setBold方法代码示例

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


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

示例1: 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

示例2: 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

示例3: copyFont

import org.apache.poi.ss.usermodel.Font; //导入方法依赖的package包/类
/**
 * 复制字体
 * 
 * @author      ZhengWei(HY)
 * @createDate  2017-03-18
 * @version     v1.0
 *
 * @param i_FromFont  源字体
 * @param i_ToFont    目标字体
 */
public final static void copyFont(Font i_FromFont ,Font i_ToFont)
{
    i_ToFont.setBold(              i_FromFont.getBold());
    i_ToFont.setCharSet(           i_FromFont.getCharSet());
    i_ToFont.setColor(             i_FromFont.getColor());
    i_ToFont.setFontHeight(        i_FromFont.getFontHeight());
    i_ToFont.setFontHeightInPoints(i_FromFont.getFontHeightInPoints());
    i_ToFont.setFontName(          i_FromFont.getFontName());
    i_ToFont.setItalic(            i_FromFont.getItalic());
    i_ToFont.setStrikeout(         i_FromFont.getStrikeout());
    i_ToFont.setTypeOffset(        i_FromFont.getTypeOffset());
    i_ToFont.setUnderline(         i_FromFont.getUnderline());
}
 
开发者ID:HY-ZhengWei,项目名称:hy.common.report,代码行数:24,代码来源:ExcelHelp.java

示例4: getBoldHeading

import org.apache.poi.ss.usermodel.Font; //导入方法依赖的package包/类
public CellStyle getBoldHeading() {
	if (boldHeading == null) {
		boldHeading = workbook.createCellStyle();
		
		Font font = workbook.createFont();
		font.setBold(true);
		boldHeading.setFont(font);
	}
	return boldHeading;
}
 
开发者ID:kddart,项目名称:kdxplore,代码行数:11,代码来源:CellStyleProvider.java

示例5: startExport

import org.apache.poi.ss.usermodel.Font; //导入方法依赖的package包/类
@Override public void startExport(List<? extends IExportColumn<?>> columnList) throws Exception {
	if(m_started)
		throw new IllegalArgumentException("The writer was already started");
	m_started = true;
	m_columnList = columnList;
	Workbook wb = m_workbook = createWorkbook();
	Font defaultFont = wb.createFont();
	defaultFont.setFontHeightInPoints((short) 10);
	defaultFont.setFontName("Arial");

	CellStyle dcs = m_defaultCellStyle = wb.createCellStyle();
	dcs.setFont(defaultFont);

	// FIXME Date format must be locale dependent?
	CellStyle dates = m_dateStyle = wb.createCellStyle();
	dates.setDataFormat(wb.createDataFormat().getFormat("d-m-yyyy"));
	dates.setFont(defaultFont);

	CellStyle curs = m_currencyStyle = wb.createCellStyle();
	curs.setDataFormat(wb.createDataFormat().getFormat("#,##0.00"));
	curs.setFont(defaultFont);

	CellStyle nums = m_numberStyle = wb.createCellStyle();
	nums.setDataFormat(wb.createDataFormat().getFormat("#0"));
	nums.setFont(defaultFont);

	Font headerFont = wb.createFont();
	headerFont.setFontHeightInPoints((short) 10);
	headerFont.setColor((short) 0xc);
	headerFont.setBold(true);
	headerFont.setFontName("Arial");

	CellStyle hds = m_headerStyle = wb.createCellStyle();
	hds.setBorderBottom(BorderStyle.THIN);
	hds.setDataFormat(HSSFDataFormat.getBuiltinFormat("text"));
	hds.setFont(headerFont);

	createNewSheet(columnList);
}
 
开发者ID:fjalvingh,项目名称:domui,代码行数:40,代码来源:ExcelExportWriter.java

示例6: configFont

import org.apache.poi.ss.usermodel.Font; //导入方法依赖的package包/类
private void configFont(Font font) {
    font.setBold(isBold());
    font.setItalic(isItalic());
    font.setStrikeout(isStrikeout());
    font.setUnderline(isUnderline() ? Font.U_SINGLE : Font.U_NONE);
    if (getFontSize() != null) {
        font.setFontHeightInPoints(fontSize.shortValue());
    }
    if (getFontColor() != null) {
        if (font instanceof XSSFFont) {
            ((XSSFFont)font).setColor(new XSSFColor(toRgbByte(fontColor)));
        } else {
            font.setColor(fontColor.getIndex());
        }
    }
}
 
开发者ID:tecsinapse,项目名称:tecsinapse-data-io,代码行数:17,代码来源:TableCellStyle.java

示例7: setBold

import org.apache.poi.ss.usermodel.Font; //导入方法依赖的package包/类
/**
 * Set a bold font for the given cell with a given font size (in pt).
 * 
 * @param wb
 *            the workbook that contains the cell
 * @param cell
 *            the cell where the text is contained
 * @param size
 *            the size in pt of the text
 */
public static void setBold(Workbook wb, HSSFCell cell, short size) {
	Font font = wb.createFont();
	font.setFontHeightInPoints((short) size);
	font.setFontName("Arial");
	font.setColor(IndexedColors.BLACK.getIndex());
	font.setBold(true);
	font.setItalic(false);

	CellStyle style = wb.createCellStyle();
	style.setFont(font);
	cell.setCellStyle(style);
}
 
开发者ID:turnus,项目名称:turnus,代码行数:23,代码来源:PoiUtils.java

示例8: createFont

import org.apache.poi.ss.usermodel.Font; //导入方法依赖的package包/类
@Override
public PoiFont createFont(com.dua3.utility.text.Font font) {
    Font poiFont = poiWorkbook.createFont();
    poiFont.setFontName(font.getFamily());
    poiFont.setFontHeight(((short) Math.round(20*font.getSizeInPoints())));
    poiFont.setColor(getPoiColor(font.getColor()).getIndex());
    poiFont.setBold(font.isBold());
    poiFont.setItalic(font.isItalic());
    poiFont.setUnderline(font.isUnderlined() ? org.apache.poi.ss.usermodel.Font.U_SINGLE
            : org.apache.poi.ss.usermodel.Font.U_NONE);
    poiFont.setStrikeout(font.isStrikeThrough());
    return new PoiFont(this, poiFont);
}
 
开发者ID:xzel23,项目名称:meja,代码行数:14,代码来源:PoiWorkbook.java

示例9: createHeaderStyle

import org.apache.poi.ss.usermodel.Font; //导入方法依赖的package包/类
private CellStyle createHeaderStyle(){
    //TO-DO read style information from sakai.properties
    Font font = gradesWorkbook.createFont();
    font.setFontName(HSSFFont.FONT_ARIAL);
    font.setColor(IndexedColors.PLUM.getIndex());
    font.setBold(true);
    CellStyle cellStyle = gradesWorkbook.createCellStyle();
    cellStyle.setFont(font);
    return cellStyle;
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:11,代码来源:SpreadsheetExporter.java

示例10: RosterWriter

import org.apache.poi.ss.usermodel.Font; //导入方法依赖的package包/类
public RosterWriter(Roster roster) {
    this.roster = roster;
    workbook = new XSSFWorkbook();
    headerStyle = workbook.createCellStyle();
    Font font = workbook.createFont();
    font.setBold(true);
    headerStyle.setFont(font);
    nonExistingStyle = createStyle(NON_EXISTING_COLOR);
    lockedByUserStyle = createStyle(LOCKED_BY_USER_COLOR);
    unavailableStyle = createStyle(UNAVAILABLE_COLOR);
}
 
开发者ID:kiegroup,项目名称:optaplanner-training,代码行数:12,代码来源:WorkerRosteringSolutionFileIO.java

示例11: XLSXWriter

import org.apache.poi.ss.usermodel.Font; //导入方法依赖的package包/类
/**
 * @param file                指定调用{@link #endWrite()}时,将缓存数据写入的文件
 * @param limit               指定每一页最多写入多少行数据(包括标题),达到此限定值则换页,&lt;=0表示不限制
 *                            ,所有数据会写在一个Sheet中(注意,若此页已经达到Excel规定最大值1048576,则会强制换页)
 * @param properties          指定需要被写入Excel文档的属性名(根据此值判断datas里元素的哪些属性会被写入),
 *                            指定为null则在写入数据时会默认写入每一个数据的所有属性
 * @param isSkipBlankRow      指定是否跳过空行,即空行是否会被写入,true表示不会写入空行,false表示会写入空行
 * @param excludeProps        指定不需要被写入Excel文档的属性名(根据此值判断datas里元素的哪些属性不会被写入),若为null表示不排除任何属性写入
 * @param dateFormat          指定要到日期类型是写入日期的格式,若为null表示使用默认值
 * @param isCompressTempFiles 指定写入缓存时缓存文件是否需要压缩,若不压缩缓存文件可能占用大量硬盘容量
 *                            (23MB的CSV数据转换成Excel时缓存数据会超过1GB,故建议压缩)
 * @param titles              写入每一页第1行的标题(1-based),指定此属性需要开启标题写入总开关{@link #isWriteTitle}
 * @param isWriteTitle        是否写入标题,注意,若为false则{@link #titles}即便为不null也不会写入标题,
 *                            若为true而{@link #titles}为Null则{@link #titles}将会被自动赋值为properties,
 *                            若为true而{@link #titles}不为null,则将会按照指定{@link #titles}写入标题
 */
public XLSXWriter(File file, int limit, List<String> properties, boolean isSkipBlankRow, List<String> excludeProps,
                  String dateFormat, boolean isCompressTempFiles, List<String> titles, boolean isWriteTitle) {
    if (limit > ROW_MOST) {
        //每一页行数不能超过最大值
        throw new WriteExcelRuntimeException("limit have to <= " + ROW_MOST);
    }
    if (properties != null && properties.size() > COLUMN_MOST) {
        //列数不能超过最大值
        throw new WriteExcelRuntimeException("properties.size() have to <= " + COLUMN_MOST);
    }
    if (isWriteTitle && titles != null && properties == null) {
        //若用户打开了标题写入总开关且指定了titles,则必须指定properties
        throw new WriteExcelRuntimeException("properties can't be null");
    }
    if (isWriteTitle && titles != null && titles.size() > COLUMN_MOST) {
        //列数不能超过最大值
        throw new WriteExcelRuntimeException("titles.size() have to <= " + COLUMN_MOST);
    }
    this.file = file;
    this.limit = limit;
    this.properties = properties;
    this.isSkipBlankRow = isSkipBlankRow;
    this.excludeProps = excludeProps;
    if (dateFormat != null) {
        this.dateFormat.applyPattern(dateFormat);
    }
    this.titles = titles;
    this.isWriteTitle = isWriteTitle;

    this.workbook = new SXSSFWorkbook(-1);
    this.workbook.setCompressTempFiles(isCompressTempFiles);
    this.defaultCellStyle = this.workbook.createCellStyle();
    this.defaultCellStyle.setFont(this.workbook.createFont());
    this.defaultCellStyle.setAlignment(CellStyle.ALIGN_CENTER);
    this.defaultCellStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER);

    if (this.isWriteTitle) {
        this.defaultTitleCellStyle = this.workbook.createCellStyle();
        Font font = this.workbook.createFont();
        font.setBold(true);
        font.setFontHeightInPoints((short) 16);
        this.defaultTitleCellStyle.setFont(font);
        this.defaultTitleCellStyle.setAlignment(CellStyle.ALIGN_CENTER);
        this.defaultTitleCellStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
    }
}
 
开发者ID:FlyingHe,项目名称:UtilsMaven,代码行数:63,代码来源:XLSXWriter.java

示例12: setupStyles

import org.apache.poi.ss.usermodel.Font; //导入方法依赖的package包/类
/**
 * Setup styles.
 */
private void setupStyles() {
    styleTitle = wb.createCellStyle();
    Font title_font = wb.createFont();
    title_font.setFontName("Helvetica");
    title_font.setColor(IndexedColors.BLACK.getIndex());
    title_font.setFontHeightInPoints((short) 24);
    styleTitle.setFont(title_font);

    styleSubtitle = wb.createCellStyle();
    Font subtitle_font = wb.createFont();
    subtitle_font.setFontName("Helvetica");
    subtitle_font.setColor(IndexedColors.GREY_50_PERCENT.getIndex());
    subtitle_font.setFontHeightInPoints((short) 18);
    styleSubtitle.setFont(subtitle_font);

    styleHyperlink = wb.createCellStyle();
    Font hlink_font = wb.createFont();
    hlink_font.setFontName("Helvetica");
    hlink_font.setUnderline(Font.U_SINGLE);
    hlink_font.setColor(IndexedColors.BLUE.getIndex());
    styleHyperlink.setFont(hlink_font);

    styleNormal = wb.createCellStyle();
    Font normal_font = wb.createFont();
    normal_font.setFontName("Helvetica");
    normal_font.setColor(IndexedColors.BLACK.getIndex());
    normal_font.setFontHeightInPoints((short) 12);
    styleNormal.setFont(normal_font);
    styleNormal.setWrapText(true);

    styleHeader = wb.createCellStyle();
    Font header_font = wb.createFont();
    header_font.setFontName("Helvetica");
    header_font.setColor(IndexedColors.WHITE.getIndex());
    header_font.setBold(true);
    header_font.setFontHeightInPoints((short) 12);
    XSSFColor bg = new XSSFColor(new java.awt.Color(0x28, 0x60, 0x90));
    ((XSSFCellStyle) styleHeader).setFillForegroundColor(bg);
    styleHeader.setFillPattern(CellStyle.SOLID_FOREGROUND);
    styleHeader.setFont(header_font);

}
 
开发者ID:frizbog,项目名称:gedantic,代码行数:46,代码来源:WorkbookCreator.java

示例13: createStyles

import org.apache.poi.ss.usermodel.Font; //导入方法依赖的package包/类
private Map<String, CellStyle> createStyles(Workbook wb){
    Map<String, CellStyle> styles = new HashMap<>();
    CellStyle style;

    Font titleFont = wb.createFont();
    titleFont.setFontHeightInPoints((short)12);
    titleFont.setBold(true);
    style = wb.createCellStyle();
    style.setAlignment(HorizontalAlignment.CENTER);
    style.setVerticalAlignment(VerticalAlignment.CENTER);
    style.setFillForegroundColor( IndexedColors.GREY_25_PERCENT.getIndex());
    style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
    style.setFont(titleFont);
    style.setWrapText(false);
    style.setBorderBottom(BorderStyle.THIN);
    style.setBottomBorderColor(IndexedColors.GREY_80_PERCENT.getIndex());
    styles.put("header", style);

    Font cellFont = wb.createFont();
    cellFont.setFontHeightInPoints((short)10);
    cellFont.setBold(true);

    style = wb.createCellStyle();
    style.setAlignment(HorizontalAlignment.RIGHT);
    style.setVerticalAlignment(VerticalAlignment.BOTTOM);
    style.setFont(cellFont);
    style.setWrapText(false);
    style.setDataFormat(wb.createDataFormat().getFormat( BuiltinFormats.getBuiltinFormat( 3 )));
    styles.put("integer_number_cell", style);

    style = wb.createCellStyle();
    style.setAlignment(HorizontalAlignment.RIGHT);
    style.setVerticalAlignment(VerticalAlignment.BOTTOM);
    style.setFont(cellFont);
    style.setWrapText(false);
    style.setDataFormat(wb.createDataFormat().getFormat(BuiltinFormats.getBuiltinFormat(4)));
    styles.put("decimal_number_cell", style);

    style = wb.createCellStyle();
    style.setAlignment(HorizontalAlignment.LEFT);
    style.setVerticalAlignment(VerticalAlignment.BOTTOM);
    style.setFont(cellFont);
    style.setWrapText(false);
    style.setDataFormat( (short) BuiltinFormats.getBuiltinFormat("text") );
    styles.put(TEXT_CELL, style);

    style = wb.createCellStyle();
    style.setAlignment(HorizontalAlignment.CENTER);
    style.setVerticalAlignment(VerticalAlignment.BOTTOM);
    style.setFont(cellFont);
    style.setWrapText(false);
    style.setDataFormat(wb.createDataFormat().getFormat( DateFormatConverter.convert( Locale.getDefault(), dateFormatPattern )));
    styles.put("date_cell", style);
    return styles;
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:56,代码来源:DataSetExportServicesImpl.java

示例14: getHeaderStyle

import org.apache.poi.ss.usermodel.Font; //导入方法依赖的package包/类
private CellStyle getHeaderStyle( Workbook workbook ) {

		CellStyle headerStyle = workbook.createCellStyle();
		Font headerFont  = workbook.createFont();

		headerFont.setBold( true );
		headerStyle.setFillBackgroundColor( HSSFColor.GREY_40_PERCENT.index );
		headerStyle.setFont( headerFont );
		return headerStyle;

	}
 
开发者ID:NyBatis,项目名称:NyBatisCore,代码行数:12,代码来源:ExcelHandlerApachePoi.java


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