當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。