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


Java XSSFColor类代码示例

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


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

示例1: createBackgroundColorXSSFCellStyle

import org.apache.poi.xssf.usermodel.XSSFColor; //导入依赖的package包/类
/**
 * @param wb
 * @param color
 * @param foreGround
 * @return
 */
public static XSSFCellStyle createBackgroundColorXSSFCellStyle(XSSFWorkbook wb,XSSFColor color,short foreGround){
	String message="XSSFWorkbook must not be null!";
	Objects.requireNonNull(wb, () -> message);
	XSSFCellStyle cellStyle=wb.createCellStyle();
	cellStyle.setWrapText(true);
	cellStyle.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);
	cellStyle.setAlignment(XSSFCellStyle.ALIGN_CENTER);
	cellStyle.setBorderBottom(BorderStyle.THIN);
	cellStyle.setBorderLeft(BorderStyle.THIN);
	cellStyle.setBorderTop(BorderStyle.THIN);
	cellStyle.setBorderRight(BorderStyle.THIN);
	cellStyle.setFillForegroundColor(color);
	cellStyle.setFillPattern(foreGround);
	return cellStyle;
}
 
开发者ID:gp15237125756,项目名称:PoiExcelExport,代码行数:22,代码来源:XSSFCellUtil.java

示例2: createColorXSSFFont

import org.apache.poi.xssf.usermodel.XSSFColor; //导入依赖的package包/类
/**
 * @param wb
 * @param fontFamily
 * @param height
 * @param color
 * @param bold
 * @return
 */
public static XSSFFont createColorXSSFFont(XSSFWorkbook wb,String fontFamily,short height,XSSFColor color,boolean bold){
	String message="XSSFWorkbook must not be null!";
	Objects.requireNonNull(wb, () -> message);
	XSSFFont cellfont=wb.createFont();
	cellfont.setFontName(fontFamily);
	cellfont.setFontHeightInPoints(height);
	cellfont.setColor(color);
	if(bold){
		cellfont.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD);
	}
	return cellfont;
}
 
开发者ID:gp15237125756,项目名称:PoiExcelExport,代码行数:21,代码来源:XSSFontUtil.java

示例3: getColor

import org.apache.poi.xssf.usermodel.XSSFColor; //导入依赖的package包/类
/**
 * Gets the {@link Color} form the given {@link XSSFColor}.
 * 
 * @param color
 *            the {@link XSSFColor}
 * @return the {@link Color} form the given {@link XSSFColor}
 */
private Color getColor(XSSFColor color) {
    final Color res;

    if (color != null && color.getRGB() != null) {
        final byte[] rgb = color.getRGB();
        final int r = rgb[0] & MASK;
        final int g = rgb[1] & MASK;
        final int b = rgb[2] & MASK;
        res = new Color(r, g, b);
    } else {
        res = null;
    }

    return res;
}
 
开发者ID:ObeoNetwork,项目名称:M2Doc,代码行数:23,代码来源:ExcelServices.java

示例4: styleColor

import org.apache.poi.xssf.usermodel.XSSFColor; //导入依赖的package包/类
public void styleColor(Formatter out, String attr, Color color) {
    XSSFColor xSSFColor = (XSSFColor) color;
    if (color == null || xSSFColor.isAuto())
        return;

    byte[] rgb = xSSFColor.getRgb();
    if (rgb == null) {
        return;
    }
    out.format("  %s: #%02x%02x%02x;%n", attr, rgb[0], rgb[1], rgb[2]);
}
 
开发者ID:xiaolanglang,项目名称:easypoi,代码行数:12,代码来源:StylerHelper.java

示例5: configFont

import org.apache.poi.xssf.usermodel.XSSFColor; //导入依赖的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

示例6: createPoiFont

import org.apache.poi.xssf.usermodel.XSSFColor; //导入依赖的package包/类
private static org.apache.poi.ss.usermodel.Font createPoiFont(PoiWorkbook workbook, Font other) {
    org.apache.poi.ss.usermodel.Font poiFont = workbook.getPoiWorkbook().createFont();
    poiFont.setFontHeightInPoints((short) Math.round(other.getSizeInPoints()));
    poiFont.setFontName(other.getFamily());

    final org.apache.poi.ss.usermodel.Color poiTextColor = workbook.getPoiColor(other.getColor());
    if (poiFont instanceof HSSFFont && poiTextColor instanceof HSSFColor) {
        poiFont.setColor(((HSSFColor) poiTextColor).getIndex());
    } else if (poiFont instanceof XSSFFont && poiTextColor instanceof XSSFColor) {
        ((XSSFFont) poiFont).setColor((XSSFColor) poiTextColor);
    } else {
        // it should both either be XSSF _or_ HSSF implementations so this
        // line should never be reached.
        throw new IllegalStateException();
    }

    poiFont.setBold(other.isBold());
    poiFont.setItalic(other.isItalic());
    poiFont.setStrikeout(other.isStrikeThrough());
    poiFont.setUnderline(other.isUnderlined() ? org.apache.poi.ss.usermodel.Font.U_SINGLE
            : org.apache.poi.ss.usermodel.Font.U_NONE);

    return poiFont;
}
 
开发者ID:xzel23,项目名称:meja,代码行数:25,代码来源:PoiFont.java

示例7: setBorderStyle

import org.apache.poi.xssf.usermodel.XSSFColor; //导入依赖的package包/类
@Override
public void setBorderStyle(Direction d, BorderStyle borderStyle) {
    org.apache.poi.ss.usermodel.BorderStyle poiBorder = getPoiBorder(borderStyle);
    final Color color = borderStyle.getColor();
    XSSFColor poiColor = color == null ? null : ((PoiXssfWorkbook) workbook).getPoiColor(color);
    switch (d) {
    case NORTH:
        ((XSSFCellStyle) poiCellStyle).setTopBorderColor(poiColor);
        poiCellStyle.setBorderTop(poiBorder);
        break;
    case EAST:
        ((XSSFCellStyle) poiCellStyle).setRightBorderColor(poiColor);
        poiCellStyle.setBorderRight(poiBorder);
        break;
    case SOUTH:
        ((XSSFCellStyle) poiCellStyle).setBottomBorderColor(poiColor);
        poiCellStyle.setBorderBottom(poiBorder);
        break;
    case WEST:
        ((XSSFCellStyle) poiCellStyle).setLeftBorderColor(poiColor);
        poiCellStyle.setBorderLeft(poiBorder);
        break;
    default:
        throw new IllegalArgumentException();
    }
}
 
开发者ID:xzel23,项目名称:meja,代码行数:27,代码来源:PoiCellStyle.java

示例8: getCellStyle

import org.apache.poi.xssf.usermodel.XSSFColor; //导入依赖的package包/类
/**
 * @param color
 * @param font
 * @return CellStyle
 */
protected XSSFCellStyle getCellStyle(XSSFColor color, Font font) {
	XSSFCellStyle style = wb.createCellStyle();
	style.setFillForegroundColor(color);
	style.setFillPattern(CellStyle.SOLID_FOREGROUND);
	style.setAlignment(CellStyle.ALIGN_CENTER);
	style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
	style.setWrapText(true);	// new line
	
	style.setBorderBottom(CellStyle.BORDER_THIN);
	style.setBottomBorderColor(IndexedColors.BLACK.getIndex());
	style.setBorderLeft(CellStyle.BORDER_THIN);
	style.setLeftBorderColor(IndexedColors.BLACK.getIndex());
	style.setBorderRight(CellStyle.BORDER_THIN);
	style.setRightBorderColor(IndexedColors.BLACK.getIndex());
	style.setBorderTop(CellStyle.BORDER_THIN);
	style.setTopBorderColor(IndexedColors.BLACK.getIndex());
	
	if(font != null) style.setFont(font);
	
	return style;
}
 
开发者ID:spdx,项目名称:ATTIC-osit,代码行数:27,代码来源:ISheetTemplate.java

示例9: getXSSFColorString

import org.apache.poi.xssf.usermodel.XSSFColor; //导入依赖的package包/类
/**
 * XSSF色の文字列表現を取得する
 * 
 * @param color XSSF色
 * @return XSSF色の文字列表現
 */
private static String getXSSFColorString( XSSFColor color) {
    StringBuffer sb = new StringBuffer( "[");
    if ( color != null) {
        sb.append( "Indexed=").append( color.getIndexed()).append( ",");
        sb.append( "Rgb=");
        if ( color.getRgb() != null) {
            for ( byte b : color.getRgb()) {
                sb.append( String.format( "%02x", b).toUpperCase());
            }
        }
        sb.append( ",");
        sb.append( "Tint=").append( color.getTint()).append( ",");
        sb.append( "Theme=").append( color.getTheme()).append( ",");
        sb.append( "Auto=").append( color.isAuto());
    }
    return sb.append( "]").toString();
}
 
开发者ID:excella-core,项目名称:excella-pdfexporter,代码行数:24,代码来源:ReportsTestUtil.java

示例10: getXSSFColorString

import org.apache.poi.xssf.usermodel.XSSFColor; //导入依赖的package包/类
private static String getXSSFColorString( XSSFColor color) {
    StringBuffer sb = new StringBuffer( "[");
    if ( color != null) {
        sb.append( "Indexed=").append( color.getIndexed()).append( ",");
        sb.append( "Rgb=");
        if ( color.getRGB() != null) {
            for ( byte b : color.getRGB()) {
                sb.append( String.format( "%02x", b).toUpperCase());
            }
        }
        sb.append( ",");
        sb.append( "Tint=").append( color.getTint()).append( ",");
        sb.append( "Theme=").append( color.getTheme()).append( ",");
        sb.append( "Auto=").append( color.isAuto());
    }
    return sb.append( "]").toString();
}
 
开发者ID:excella-core,项目名称:excella-core,代码行数:18,代码来源:TestUtil.java

示例11: getXSSFColorString

import org.apache.poi.xssf.usermodel.XSSFColor; //导入依赖的package包/类
/**
 * XSSF色の文字列表現を取得する
 * 
 * @param color XSSF色
 * @return XSSF色の文字列表現
 */
private static String getXSSFColorString( XSSFColor color) {
    StringBuffer sb = new StringBuffer( "[");
    if ( color != null) {
        sb.append( "Indexed=").append( color.getIndexed()).append( ",");
        sb.append( "Rgb=");
        if ( color.getRGB() != null) {
            for ( byte b : color.getRGB()) {
                sb.append( String.format( "%02x", b).toUpperCase());
            }
        }
        sb.append( ",");
        sb.append( "Tint=").append( color.getTint()).append( ",");
        sb.append( "Theme=").append( color.getTheme()).append( ",");
        sb.append( "Auto=").append( color.isAuto());
    }
    return sb.append( "]").toString();
}
 
开发者ID:excella-core,项目名称:excella-reports,代码行数:24,代码来源:ReportsTestUtil.java

示例12: addColourToFont

import org.apache.poi.xssf.usermodel.XSSFColor; //导入依赖的package包/类
@Override
public void addColourToFont(Workbook workbook, Font font, String colour) {
	if(colour == null) {
		return ;
	}
	if(IStyle.TRANSPARENT_VALUE.equals(colour)) {
		return ;
	}
	if(font instanceof XSSFFont) {
		XSSFFont xFont = (XSSFFont)font;
		XSSFColor xColour = getXColour(colour);
		
		if(xColour != null) {
			xFont.setColor(xColour);
		}
	}
}
 
开发者ID:eclipse,项目名称:birt,代码行数:18,代码来源:StyleManagerXUtils.java

示例13: addBackgroundColourToStyle

import org.apache.poi.xssf.usermodel.XSSFColor; //导入依赖的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 XSSFCellStyle) {
		XSSFCellStyle cellStyle = (XSSFCellStyle)style;
		XSSFColor xColour = getXColour(colour);
		if(xColour != null) {
			cellStyle.setFillForegroundColor(xColour);
			cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
		}
	}
}
 
开发者ID:eclipse,项目名称:birt,代码行数:18,代码来源:StyleManagerXUtils.java

示例14: correctFontColorIfBackground

import org.apache.poi.xssf.usermodel.XSSFColor; //导入依赖的package包/类
@Override
public Font correctFontColorIfBackground( FontManager fm, Workbook wb, BirtStyle birtStyle, Font font ) {
	CSSValue bgColour = birtStyle.getProperty( StyleConstants.STYLE_BACKGROUND_COLOR );
	int bgRgb[] = parseColour( bgColour == null ? null : bgColour.getCssText(), "white" );

	XSSFColor colour = ((XSSFFont)font).getXSSFColor();
	int fgRgb[] = rgbOnly( colour.getARgb() );
	if( ( fgRgb[0] == 255 ) && ( fgRgb[1] == 255 ) && ( fgRgb[2] == 255 ) ) {
		fgRgb[0]=fgRgb[1]=fgRgb[2]=0;
	} else if( ( fgRgb[0] == 0 ) && ( fgRgb[1] == 0 ) && ( fgRgb[2] == 0 ) ) {
		fgRgb[0]=fgRgb[1]=fgRgb[2]=255;
	}

	if( ( bgRgb[ 0 ] == fgRgb[ 0 ] ) && ( bgRgb[ 1 ] == fgRgb[ 1 ] ) && ( bgRgb[ 2 ] == fgRgb[ 2 ] ) ) {
		
		IStyle addedStyle = new AreaStyle( fm.getCssEngine() );
		addedStyle.setColor( contrastColour( bgRgb ) );
		
		return fm.getFontWithExtraStyle( font, addedStyle );
	} else {
		return font;
	}
}
 
开发者ID:eclipse,项目名称:birt,代码行数:24,代码来源:StyleManagerXUtils.java

示例15: getRgbWithTint

import org.apache.poi.xssf.usermodel.XSSFColor; //导入依赖的package包/类
private static byte[] getRgbWithTint(XSSFColor c) {
	byte[] rgb = c.getCTColor().getRgb();
	double tint = c.getTint();
	if (rgb != null && tint != 0.0) {
		if(rgb.length == 4) {
			byte[] tmp = new byte[3];
			System.arraycopy(rgb, 1, tmp, 0, 3);
			rgb = tmp;
		}
		for (int i=0; i<rgb.length; i++) {
			int lum = rgb[i] & 0xFF;
			double d = sRGB_to_scRGB(lum / 255.0);
			d = tint > 0 ? d * (1.0 - tint) + tint : d * (1 + tint);
			d = scRGB_to_sRGB(d);
			rgb[i] = (byte)Math.round(d * 255.0);
		}
	}
	return rgb;
}
 
开发者ID:shunjikonishi,项目名称:excel2canvas,代码行数:20,代码来源:ExcelColor.java


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