Java Code Examples for org.apache.poi.hssf.usermodel.HSSFCellStyle#setRightBorderColor()

The following examples show how to use org.apache.poi.hssf.usermodel.HSSFCellStyle#setRightBorderColor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: POIUtils.java    From ermasterr with Apache License 2.0 7 votes vote down vote up
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;
    }
 
Example 2
Source File: POIUtils.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 3
Source File: StyleManagerHUtils.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void applyBorderStyle(Workbook workbook, CellStyle style, BorderSide side, CSSValue colour, CSSValue borderStyle, CSSValue width) {
	if( ( colour != null ) || ( borderStyle != null ) || ( width != null ) ) {
		String colourString = colour == null ? "rgb(0,0,0)" : colour.getCssText();
		String borderStyleString = borderStyle == null ? "solid" : borderStyle.getCssText();
		String widthString = width == null ? "medium" : width.getCssText();

		if( style instanceof HSSFCellStyle ) {
			HSSFCellStyle hStyle = (HSSFCellStyle)style;
			
			short hBorderStyle = poiBorderStyleFromBirt(borderStyleString, widthString);
			short colourIndex = getHColour((HSSFWorkbook)workbook, colourString);
			if( colourIndex > 0 ) {
				if(hBorderStyle != CellStyle.BORDER_NONE) {
					switch( side ) {
					case TOP:
						hStyle.setBorderTop(hBorderStyle);
						hStyle.setTopBorderColor(colourIndex);
						// log.debug( "Top border: " + xStyle.getBorderTop() + " / " + xStyle.getTopBorderXSSFColor().getARGBHex() );
						break;
					case LEFT:
						hStyle.setBorderLeft(hBorderStyle);
						hStyle.setLeftBorderColor(colourIndex);
						// log.debug( "Left border: " + xStyle.getBorderLeft() + " / " + xStyle.getLeftBorderXSSFColor().getARGBHex() );
						break;
					case RIGHT:
						hStyle.setBorderRight(hBorderStyle);
						hStyle.setRightBorderColor(colourIndex);
						// log.debug( "Right border: " + xStyle.getBorderRight() + " / " + xStyle.getRightBorderXSSFColor().getARGBHex() );
						break;
					case BOTTOM:
						hStyle.setBorderBottom(hBorderStyle);
						hStyle.setBottomBorderColor(colourIndex);
						// log.debug( "Bottom border: " + xStyle.getBorderBottom() + " / " + xStyle.getBottomBorderXSSFColor().getARGBHex() );
						break;
					}
				}
			}
		}
	}
}