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


Java HSSFCellStyle.setFillForegroundColor方法代码示例

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


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

示例1: getCellStyle

import org.apache.poi.hssf.usermodel.HSSFCellStyle; //导入方法依赖的package包/类
/**
 * 获取单元格式样式
 *
 * @param wb
 * @param color
 * @return
 */
private static HSSFCellStyle getCellStyle(HSSFWorkbook wb, int color) {
    if (STYLE_MAP.get(color) != null) {
        return STYLE_MAP.get(color);
    }
    HSSFCellStyle style = wb.createCellStyle();
    if (color != -1) {
        style.setFillForegroundColor(Short.valueOf(color + ""));
        style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
        style.setAlignment(CellStyle.ALIGN_CENTER);
    }
    style.setBorderBottom(CellStyle.BORDER_THIN);
    style.setBorderLeft(CellStyle.BORDER_THIN);
    style.setBorderRight(CellStyle.BORDER_THIN);
    style.setBorderTop(CellStyle.BORDER_THIN);
    style.setBottomBorderColor(HSSFColor.BLACK.index);
    style.setLeftBorderColor(HSSFColor.BLACK.index);
    style.setRightBorderColor(HSSFColor.BLACK.index);
    style.setTopBorderColor(HSSFColor.BLACK.index);
    STYLE_MAP.put(color, style);
    return style;
}
 
开发者ID:ajtdnyy,项目名称:PackagePlugin,代码行数:29,代码来源:FileUtil.java

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

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

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

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

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

示例8: addBackgroundColourToStyle

import org.apache.poi.hssf.usermodel.HSSFCellStyle; //导入方法依赖的package包/类
@Override
public void addBackgroundColourToStyle(Workbook workbook, CellStyle style, String colour) {
	if(colour == null) {
		return ;
	}
	if(IStyle.TRANSPARENT_VALUE.equals(colour)) {
		return ;
	}
	if(style instanceof HSSFCellStyle) {
		HSSFCellStyle cellStyle = (HSSFCellStyle)style;
		short colourIndex = getHColour((HSSFWorkbook)workbook, colour);
		if( colourIndex > 0 ) {
			cellStyle.setFillForegroundColor(colourIndex);
			cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
		}
	}
}
 
开发者ID:eclipse,项目名称:birt,代码行数:18,代码来源:StyleManagerHUtils.java

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

示例10: test_001

import org.apache.poi.hssf.usermodel.HSSFCellStyle; //导入方法依赖的package包/类
@Test
public void test_001()
{
    HSSFWorkbook v_Workbook = new HSSFWorkbook();
    HSSFSheet    v_Sheet    = v_Workbook.createSheet("测试单元格颜色");
    
    v_Sheet.setColumnWidth(0 ,2560);
    
    for (int v_RowIndex=0; v_RowIndex<4000; v_RowIndex++)
    {
        HSSFRow v_Row = v_Sheet.createRow(v_RowIndex);
        
        for (int v_ColIndex=0; v_ColIndex<1; v_ColIndex++)
        {
            HSSFCell      v_Cell = v_Row.createCell(v_ColIndex);
            HSSFCellStyle v_CellStyle = v_Workbook.createCellStyle();
            
            v_CellStyle.setFillForegroundColor((short)(v_RowIndex + 1));
            v_CellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
            
            v_Cell.setCellStyle(v_CellStyle);
            v_Cell.setCellValue("" + (v_RowIndex + 1));
        }
    }
    
    ExcelHelp.save(v_Workbook ,"/Users/hy/Downloads/测试2003版本的单元格颜色");
}
 
开发者ID:HY-ZhengWei,项目名称:hy.common.report,代码行数:28,代码来源:JU_Excel2003Color.java

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

示例12: copyCellStyle

import org.apache.poi.hssf.usermodel.HSSFCellStyle; //导入方法依赖的package包/类
public static HSSFCellStyle copyCellStyle(HSSFWorkbook workbook,
		HSSFCellStyle style) {

	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());

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

	return newCellStyle;
}
 
开发者ID:kozake,项目名称:ermaster-k,代码行数:31,代码来源:POIUtils.java

示例13: generateHeaderStyle

import org.apache.poi.hssf.usermodel.HSSFCellStyle; //导入方法依赖的package包/类
/**
 * Description: 生成表格的 头部的单元格样式
 * @param workbook
 * @return
 *
 * @History
 *     1. 2014-12-19 linwb 创建方法
 */
private HSSFCellStyle generateHeaderStyle(HSSFWorkbook workbook) {
    //生成表格头部标题栏样式
    HSSFCellStyle headerStyle = workbook.createCellStyle();
    // 设置这些样式
    headerStyle.setFillForegroundColor(headerCellBackgroundColor);
    headerStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
    
    headerStyle.setBorderBottom(headerBorderBottom);
    headerStyle.setBorderLeft(headerBorderLeft);
    headerStyle.setBorderRight(headerBorderRight);
    headerStyle.setBorderTop(headerBorderTop);
    
    headerStyle.setAlignment(headerCellTextAlign);
    headerStyle.setVerticalAlignment(headerCellVehicleAlign);
    
    // 生成字体
    HSSFFont font = workbook.createFont();
    font.setColor(headerFontColor);
    font.setFontHeightInPoints(headerFontHeight);
    font.setBoldweight(headerFontWeight);
    
    // 把字体应用到当前的样式
    headerStyle.setFont(font);
    
    return headerStyle;
}
 
开发者ID:webinglin,项目名称:excelExportor,代码行数:35,代码来源:ExcelExportor.java

示例14: createHeaderStyle

import org.apache.poi.hssf.usermodel.HSSFCellStyle; //导入方法依赖的package包/类
public HSSFCellStyle createHeaderStyle() {
    HSSFCellStyle style = workbook.createCellStyle();
    final HSSFFont font = workbook.createFont();
    font.setBold(true);
    style.setFont(font);
    style.setBorderBottom(BorderStyle.THIN);
    style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
    style.setVerticalAlignment(VerticalAlignment.CENTER);
    style.setAlignment(HorizontalAlignment.CENTER);
    style.setFillForegroundColor(HSSFColor.HSSFColorPredefined.PALE_BLUE.getIndex());
    return style;
}
 
开发者ID:JumpMind,项目名称:sqlexplorer-vaadin,代码行数:13,代码来源:ExcelExport.java

示例15: postProcessXLS

import org.apache.poi.hssf.usermodel.HSSFCellStyle; //导入方法依赖的package包/类
public void postProcessXLS(Object document) {  
    HSSFWorkbook wb = (HSSFWorkbook) document;  
    HSSFSheet sheet = wb.getSheetAt(0);  
    HSSFRow header = sheet.getRow(0);  
      
    HSSFCellStyle cellStyle = wb.createCellStyle();    
    cellStyle.setFillForegroundColor(HSSFColor.GREEN.index);  
    cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);  
      
    for(int i=0; i < header.getPhysicalNumberOfCells();i++) {  
        HSSFCell cell = header.getCell(i);  
          
        cell.setCellStyle(cellStyle);  
    }  
    
    Row row=sheet.createRow((short)sheet.getLastRowNum()+3);
    Cell cellDisclaimer = row.createCell(0);
    HSSFFont customFont= wb.createFont();
    customFont.setFontHeightInPoints((short)10);
    customFont.setFontName("Arial");
    customFont.setColor(IndexedColors.BLACK.getIndex());
    customFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
    customFont.setItalic(true);
    
    cellDisclaimer.setCellValue("Disclaimer");
    HSSFCellStyle cellStyleDisclaimer = wb.createCellStyle();
    cellStyleDisclaimer.setFont(customFont);
    cellDisclaimer.setCellStyle(cellStyleDisclaimer);
    
    Row row1=sheet.createRow(sheet.getLastRowNum()+2);
    Cell cellDisclaimerContent1 = row1.createCell(0);
    cellDisclaimerContent1.setCellValue("The information contained in this website is for information purposes only, and does not constitute, nor is it intended to constitute, the provision of financial product advice.");
    
    Row row2=sheet.createRow(sheet.getLastRowNum()+1);
    Cell cellDisclaimerContent2 = row2.createCell(0);
    cellDisclaimerContent2.setCellValue("This website is intended to track the investor account summary information,investments and transaction in a partcular period of time. ");
    
}
 
开发者ID:sudheerj,项目名称:primefaces-blueprints,代码行数:39,代码来源:InvestmentSummaryController.java


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