當前位置: 首頁>>代碼示例>>Java>>正文


Java HSSFCellStyle.setFont方法代碼示例

本文整理匯總了Java中org.apache.poi.hssf.usermodel.HSSFCellStyle.setFont方法的典型用法代碼示例。如果您正苦於以下問題:Java HSSFCellStyle.setFont方法的具體用法?Java HSSFCellStyle.setFont怎麽用?Java HSSFCellStyle.setFont使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.poi.hssf.usermodel.HSSFCellStyle的用法示例。


在下文中一共展示了HSSFCellStyle.setFont方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createHSSFCellStyle

import org.apache.poi.hssf.usermodel.HSSFCellStyle; //導入方法依賴的package包/類
private HSSFCellStyle createHSSFCellStyle(Workbook wb, int[] bgColor, int[] fontColor, int fontSize) {
	HSSFWorkbook workbook = (HSSFWorkbook) wb;
	HSSFPalette palette = workbook.getCustomPalette();
	
	palette.setColorAtIndex((short) 9, (byte) fontColor[0], (byte) fontColor[1], (byte) fontColor[2]);
	palette.setColorAtIndex((short) 10, (byte) bgColor[0], (byte) bgColor[1], (byte) bgColor[2]);

	HSSFFont titleFont = workbook.createFont();
	titleFont.setCharSet(HSSFFont.DEFAULT_CHARSET);
	titleFont.setFontName("宋體");
	titleFont.setColor((short) 9);
	titleFont.setBold(true); 
	titleFont.setFontHeightInPoints((short) fontSize);

	HSSFCellStyle titleStyle = (HSSFCellStyle) createBorderCellStyle(workbook, true);
	titleStyle.setFont(titleFont);
	titleStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
	titleStyle.setFillForegroundColor((short) 10);
	titleStyle.setAlignment(HorizontalAlignment.CENTER);
	titleStyle.setVerticalAlignment(VerticalAlignment.CENTER);

	return titleStyle;
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:24,代碼來源:TitleStyleBuilder.java

示例2: createColumnHeaders

import org.apache.poi.hssf.usermodel.HSSFCellStyle; //導入方法依賴的package包/類
/**
 */
protected void createColumnHeaders() {
	final HSSFRow headersRow = this.sheet.createRow(0);
	final HSSFFont font = this.workbook.createFont();
	font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
	final HSSFCellStyle style = this.workbook.createCellStyle();
	style.setFont(font);
	style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
	int counter = 1;
	for (int i = 0; i < this.model.getColumnCount(); i++) {
		final HSSFCell cell = headersRow.createCell(counter++);
		// cell.setEncoding(HSSFCell.ENCODING_UTF_16);
		cell.setCellValue(this.model.getColumnName(i));
		cell.setCellStyle(style);
	}
}
 
開發者ID:kiswanij,項目名稱:jk-util,代碼行數:18,代碼來源:JKExcelUtil.java

示例3: createCellStyleForColumnHeading

import org.apache.poi.hssf.usermodel.HSSFCellStyle; //導入方法依賴的package包/類
public static HSSFCellStyle createCellStyleForColumnHeading(HSSFWorkbook workBook) {
	HSSFCellStyle cellStyle = workBook.createCellStyle();
	HSSFFont fontObj = workBook.createFont();
	cellStyle.setBorderBottom(BorderStyle.THIN);
	cellStyle.setBorderTop(BorderStyle.THIN);
	cellStyle.setBorderLeft(BorderStyle.THIN);
	cellStyle.setBorderRight(BorderStyle.THIN);
	cellStyle.setWrapText(true);
	cellStyle.setAlignment(HorizontalAlignment.CENTER);
	cellStyle.setFillBackgroundColor(Short.valueOf("22").shortValue());
	cellStyle.setFillPattern(FillPatternType.BIG_SPOTS);
	cellStyle.setFillForegroundColor(Short.valueOf("22").shortValue());
	cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
	fontObj.setFontName("Calibri");
	fontObj.setFontHeightInPoints(Short.valueOf("12").shortValue());
	fontObj.setBold(true);
	fontObj.setColor(Short.valueOf("8").shortValue());
	cellStyle.setFont(fontObj);
	return cellStyle;
}
 
開發者ID:siteadmin,項目名稱:CCDA-Score-CARD,代碼行數:21,代碼來源:ScorecardExcelGenerator.java

示例4: getHeaderStyle

import org.apache.poi.hssf.usermodel.HSSFCellStyle; //導入方法依賴的package包/類
private HSSFCellStyle getHeaderStyle(final int col)
{
	String key = "header-" + col;
	HSSFCellStyle cs_header = m_styles.get(key);
	if (cs_header == null)
	{
		HSSFFont font_header = getFont(true);
		cs_header = m_workbook.createCellStyle();
		cs_header.setFont(font_header);
		cs_header.setBorderLeft((short)2);
		cs_header.setBorderTop((short)2);
		cs_header.setBorderRight((short)2);
		cs_header.setBorderBottom((short)2);
		cs_header.setDataFormat(HSSFDataFormat.getBuiltinFormat("text"));
		cs_header.setWrapText(true);
		m_styles.put(key, cs_header);
	}
	return cs_header;
}
 
開發者ID:metasfresh,項目名稱:metasfresh,代碼行數:20,代碼來源:AbstractExcelExporter.java

示例5: createSecondTitleStyle

import org.apache.poi.hssf.usermodel.HSSFCellStyle; //導入方法依賴的package包/類
private HSSFCellStyle createSecondTitleStyle(HSSFWorkbook wb){
	HSSFCellStyle style = wb.createCellStyle();
	style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
	style.setAlignment(HSSFCellStyle.ALIGN_LEFT);
	style.setBorderBottom(HSSFCellStyle.BORDER_NONE);
    style.setBorderLeft(HSSFCellStyle.BORDER_NONE);
    style.setBorderRight(HSSFCellStyle.BORDER_NONE);
    style.setBorderTop(HSSFCellStyle.BORDER_NONE);
	style.setWrapText(true);
	
	HSSFFont font = wb.createFont();
	//font.setFontHeightInPoints((short)20);
	font.setFontName("����");
	style.setFont(font);
	return style;
}
 
開發者ID:wallellen,項目名稱:wl,代碼行數:17,代碼來源:ExcelExcuter.java

示例6: generateContStyle

import org.apache.poi.hssf.usermodel.HSSFCellStyle; //導入方法依賴的package包/類
/**
 * @Description: 生成excel表格 單元格內容的樣式
 * @param workbook
 * @return
 *
 * @History
 *     1. 2014-12-19 linwb 創建方法
 */
private HSSFCellStyle generateContStyle(HSSFWorkbook workbook) {
    HSSFCellStyle cellStyle = workbook.createCellStyle();
    cellStyle.setFillForegroundColor(contCellBackgroundColor);
    cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
    
    cellStyle.setBorderBottom(contBorderBottom);
    cellStyle.setBorderLeft(contBorderLeft);
    cellStyle.setBorderRight(contBorderRight);
    cellStyle.setBorderTop(contBorderTop);
    cellStyle.setAlignment(contCellTextAlign);
    
    cellStyle.setVerticalAlignment(contCellVehicleAlign);
    // 生成字體
    HSSFFont font = workbook.createFont();
    font.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL);
    // 把字體應用到當前的樣式
    cellStyle.setFont(font);
    
    return cellStyle;
}
 
開發者ID:webinglin,項目名稱:excelExportor,代碼行數:29,代碼來源:ExcelExportor.java

示例7: estiloCabecalho

import org.apache.poi.hssf.usermodel.HSSFCellStyle; //導入方法依賴的package包/類
/**
 * Estilo de cabecalho.
 * @param wb 
 * @return retorna o estilo da celula.
 * @author Ekler Paulino de Mattos.
 */
private HSSFCellStyle estiloCabecalho(HSSFWorkbook wb){
	
	HSSFCellStyle cellStyle = wb.createCellStyle();
	cellStyle.setBorderBottom(HSSFCellStyle.BORDER_THICK);
	cellStyle.setBorderRight(HSSFCellStyle.BORDER_THICK);
	cellStyle.setBorderLeft(HSSFCellStyle.BORDER_THICK);
	cellStyle.setBorderTop(HSSFCellStyle.BORDER_THICK);
	
	cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND );
//	cellStyle.setFillForegroundColor(HSSFColor.GREY_40_PERCENT.index);
	cellStyle.setFillForegroundColor(HSSFColor.LIGHT_YELLOW.index);
	
	cellStyle.setAlignment(HSSFCellStyle.ALIGN_LEFT);
	
	HSSFFont font = cellStyle.getFont(wb);
	font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
	font.setColor(HSSFFont.COLOR_NORMAL);
	font.setFontName(HSSFFont.FONT_ARIAL);
	cellStyle.setFont(font);
	
	return cellStyle;
	
}
 
開發者ID:darciopacifico,項目名稱:omr,代碼行數:30,代碼來源:GeradorXLSRetorno.java

示例8: estiloDadosConsultado

import org.apache.poi.hssf.usermodel.HSSFCellStyle; //導入方法依賴的package包/類
/**
 * Estilo dos campos dos dados.
 * @param wb 
 * @return retorna o estilo da celula.
 * @author Ekler Paulino de Mattos.
 */
private HSSFCellStyle estiloDadosConsultado(HSSFWorkbook wb){
	
	HSSFCellStyle cellStyle = wb.createCellStyle();
	cellStyle.setBorderBottom(HSSFCellStyle.BORDER_MEDIUM);
	cellStyle.setBorderRight(HSSFCellStyle.BORDER_MEDIUM);
	cellStyle.setBorderLeft(HSSFCellStyle.BORDER_MEDIUM);
	cellStyle.setBorderTop(HSSFCellStyle.BORDER_MEDIUM);
	
	// plano de fundo - para que funcione deve se  
	// definido antes um padrao de preenchimento.
	cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND );
	//cellStyle.setFillForegroundColor(HSSFColor.AQUA.index);
	cellStyle.setFillForegroundColor(HSSFColor.WHITE.index);
	
	cellStyle.setAlignment(HSSFCellStyle.ALIGN_LEFT);
	
	HSSFFont font = cellStyle.getFont(wb);
	font.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL);
	font.setColor(HSSFFont.COLOR_NORMAL);
	font.setFontName(HSSFFont.FONT_ARIAL);
	cellStyle.setFont(font);
	
	return cellStyle;
	
}
 
開發者ID:darciopacifico,項目名稱:omr,代碼行數:32,代碼來源:GeradorXLSRetorno.java

示例9: estiloDadosRetorno

import org.apache.poi.hssf.usermodel.HSSFCellStyle; //導入方法依賴的package包/類
/**
 * Estilo dos campos dos dados.
 * @param wb 
 * @return retorna o estilo da celula.
 * @author Ekler Paulino de Mattos.
 */
private HSSFCellStyle estiloDadosRetorno(HSSFWorkbook wb){
	
	HSSFCellStyle cellStyle = wb.createCellStyle();
	cellStyle.setBorderBottom(HSSFCellStyle.BORDER_MEDIUM);
	cellStyle.setBorderRight(HSSFCellStyle.BORDER_MEDIUM);
	cellStyle.setBorderLeft(HSSFCellStyle.BORDER_MEDIUM);
	cellStyle.setBorderTop(HSSFCellStyle.BORDER_MEDIUM);
	
	// plano de fundo - para que funcione deve se  
	// definido antes um padrao de preenchimento.
	cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND );
	//cellStyle.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index);
	cellStyle.setFillForegroundColor(HSSFColor.PALE_BLUE.index);
	
	cellStyle.setAlignment(HSSFCellStyle.ALIGN_LEFT);
	
	HSSFFont font = cellStyle.getFont(wb);
	font.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL);
	font.setColor(HSSFFont.COLOR_NORMAL);
	font.setFontName(HSSFFont.FONT_ARIAL);
	cellStyle.setFont(font);
	
	return cellStyle;
	
}
 
開發者ID:darciopacifico,項目名稱:omr,代碼行數:32,代碼來源:GeradorXLSRetorno.java

示例10: writeCaption

import org.apache.poi.hssf.usermodel.HSSFCellStyle; //導入方法依賴的package包/類
/**
 * @see org.displaytag.render.TableWriterTemplate#writeCaption(org.displaytag.model.TableModel)
 */
@Override
protected void writeCaption(TableModel model) throws Exception
{
    HSSFCellStyle style = this.wb.createCellStyle();
    HSSFFont bold = this.wb.createFont();
    bold.setBoldweight(Font.BOLDWEIGHT_BOLD);
    bold.setFontHeightInPoints((short) 14);
    style.setFont(bold);
    style.setAlignment(CellStyle.ALIGN_CENTER);

    this.colNum = 0;
    this.currentRow = this.sheet.createRow(this.sheetRowNum++);
    this.currentCell = this.currentRow.createCell(this.colNum);
    this.currentCell.setCellStyle(style);
    String caption = model.getCaption();
    this.currentCell.setCellValue(new HSSFRichTextString(caption));
    this.rowSpanTable(model);
}
 
開發者ID:webbfontaine,項目名稱:displaytag,代碼行數:22,代碼來源:HssfTableWriter.java

示例11: setHeaderStyle

import org.apache.poi.hssf.usermodel.HSSFCellStyle; //導入方法依賴的package包/類
private void setHeaderStyle(HSSFWorkbook wb) {
    HSSFCellStyle style = wb.createCellStyle();
    HSSFFont font = wb.createFont();
    font.setColor(HSSFColor.BLACK.index);
    font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
    font.setFontHeightInPoints((short) 8);
    style.setFont(font);
    style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
    style.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index);
    style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
    style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    style.setBorderRight(HSSFCellStyle.BORDER_THIN);
    style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
    style.setBorderTop(HSSFCellStyle.BORDER_THIN);
    style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
    style.setWrapText(true);
    headerStyle = style;
}
 
開發者ID:FenixEdu,項目名稱:fenixedu-commons,代碼行數:19,代碼來源:ExcelStyle.java

示例12: setDoubleNegativeStyle

import org.apache.poi.hssf.usermodel.HSSFCellStyle; //導入方法依賴的package包/類
private void setDoubleNegativeStyle(HSSFWorkbook wb) {
    HSSFCellStyle style = wb.createCellStyle();
    HSSFFont font = wb.createFont();
    font.setColor(HSSFColor.BLACK.index);
    font.setFontHeightInPoints((short) 8);
    style.setFont(font);
    style.setAlignment(HSSFCellStyle.ALIGN_RIGHT);
    style.setDataFormat(wb.createDataFormat().getFormat("#,##0.00"));
    font.setColor(HSSFColor.RED.index);
    doubleNegativeStyle = style;
}
 
開發者ID:FenixEdu,項目名稱:fenixedu-commons,代碼行數:12,代碼來源:ExcelStyle.java

示例13: createHeader

import org.apache.poi.hssf.usermodel.HSSFCellStyle; //導入方法依賴的package包/類
private void createHeader(
		HSSFWorkbook wb,
		HSSFSheet sheet,
		List<TascaDadaDto> informeCamps) {
	HSSFFont bold;
	bold = wb.createFont();
	bold.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
	bold.setColor(HSSFColor.WHITE.index);
	HSSFCellStyle headerStyle;
	headerStyle = wb.createCellStyle();
	headerStyle.setFillPattern(HSSFCellStyle.FINE_DOTS);
	headerStyle.setFillBackgroundColor(HSSFColor.GREY_80_PERCENT.index);
	headerStyle.setFont(bold);
	int rowNum = 0;
	int colNum = 0;
	// Capçalera
	HSSFRow xlsRow = sheet.createRow(rowNum++);
	HSSFCell cell;
	cell = xlsRow.createCell(colNum++);
	cell.setCellValue(new HSSFRichTextString(StringUtils.capitalize("Expedient")));
	cell.setCellStyle(headerStyle);
	for (TascaDadaDto camp : informeCamps) {
		sheet.autoSizeColumn(colNum);
		cell = xlsRow.createCell(colNum++);
		cell.setCellValue(new HSSFRichTextString(StringUtils.capitalize(camp.getCampEtiqueta())));
		cell.setCellStyle(headerStyle);
	}
}
 
開發者ID:GovernIB,項目名稱:helium,代碼行數:29,代碼來源:ExpedientConsultaInformeController.java

示例14: setBold

import org.apache.poi.hssf.usermodel.HSSFCellStyle; //導入方法依賴的package包/類
private static void setBold(HSSFWorkbook workbook, HSSFCell cell) {
  HSSFCellStyle boldStyle = workbook.createCellStyle();
  HSSFFont boldFont = workbook.createFont();
  boldFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
  boldStyle.setFont(boldFont);
  cell.setCellStyle(boldStyle);
}
 
開發者ID:innovad,項目名稱:4mila-1.0,代碼行數:8,代碼來源:ExcelUtility.java

示例15: copyCellStyle

import org.apache.poi.hssf.usermodel.HSSFCellStyle; //導入方法依賴的package包/類
public static HSSFCellStyle copyCellStyle(final HSSFWorkbook workbook, final HSSFCellStyle style) {

        final HSSFCellStyle newCellStyle = workbook.createCellStyle();

        newCellStyle.setAlignment(style.getAlignment());
        newCellStyle.setBorderBottom(style.getBorderBottom());
        newCellStyle.setBorderLeft(style.getBorderLeft());
        newCellStyle.setBorderRight(style.getBorderRight());
        newCellStyle.setBorderTop(style.getBorderTop());
        newCellStyle.setBottomBorderColor(style.getBottomBorderColor());
        newCellStyle.setDataFormat(style.getDataFormat());
        newCellStyle.setFillBackgroundColor(style.getFillBackgroundColor());
        newCellStyle.setFillForegroundColor(style.getFillForegroundColor());
        newCellStyle.setFillPattern(style.getFillPattern());
        newCellStyle.setHidden(style.getHidden());
        newCellStyle.setIndention(style.getIndention());
        newCellStyle.setLeftBorderColor(style.getLeftBorderColor());
        newCellStyle.setLocked(style.getLocked());
        newCellStyle.setRightBorderColor(style.getRightBorderColor());
        newCellStyle.setRotation(style.getRotation());
        newCellStyle.setTopBorderColor(style.getTopBorderColor());
        newCellStyle.setVerticalAlignment(style.getVerticalAlignment());
        newCellStyle.setWrapText(style.getWrapText());

        final HSSFFont font = workbook.getFontAt(style.getFontIndex());
        newCellStyle.setFont(font);

        return newCellStyle;
    }
 
開發者ID:roundrop,項目名稱:ermasterr,代碼行數:30,代碼來源:POIUtils.java


注:本文中的org.apache.poi.hssf.usermodel.HSSFCellStyle.setFont方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。