本文整理了Java中org.apache.poi.ss.usermodel.CellStyle.setBottomBorderColor()
方法的一些代码示例,展示了CellStyle.setBottomBorderColor()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CellStyle.setBottomBorderColor()
方法的具体详情如下:
包路径:org.apache.poi.ss.usermodel.CellStyle
类名称:CellStyle
方法名:setBottomBorderColor
[英]set the color to use for the bottom border
[中]设置用于底部边框的颜色
代码示例来源:origin: looly/hutool
/**
* 设置cell的四个边框粗细和颜色
*
* @param cellStyle {@link CellStyle}
* @param borderSize 边框粗细{@link BorderStyle}枚举
* @param colorIndex 颜色的short值
* @return {@link CellStyle}
*/
public static CellStyle setBorder(CellStyle cellStyle, BorderStyle borderSize, IndexedColors colorIndex) {
cellStyle.setBorderBottom(borderSize);
cellStyle.setBottomBorderColor(colorIndex.index);
cellStyle.setBorderLeft(borderSize);
cellStyle.setLeftBorderColor(colorIndex.index);
cellStyle.setBorderRight(borderSize);
cellStyle.setRightBorderColor(colorIndex.index);
cellStyle.setBorderTop(borderSize);
cellStyle.setTopBorderColor(colorIndex.index);
return cellStyle;
}
代码示例来源:origin: looly/hutool
/**
* 设置cell的四个边框粗细和颜色
*
* @param cellStyle {@link CellStyle}
* @param borderSize 边框粗细{@link BorderStyle}枚举
* @param colorIndex 颜色的short值
* @return {@link CellStyle}
*/
public static CellStyle setBorder(CellStyle cellStyle, BorderStyle borderSize, IndexedColors colorIndex) {
cellStyle.setBorderBottom(borderSize);
cellStyle.setBottomBorderColor(colorIndex.index);
cellStyle.setBorderLeft(borderSize);
cellStyle.setLeftBorderColor(colorIndex.index);
cellStyle.setBorderRight(borderSize);
cellStyle.setRightBorderColor(colorIndex.index);
cellStyle.setBorderTop(borderSize);
cellStyle.setTopBorderColor(colorIndex.index);
return cellStyle;
}
代码示例来源:origin: org.apache.poi/poi
/**
* Sets the format properties of the given style based on the given map.
*
* @param style cell style
* @param workbook parent workbook
* @param properties map of format properties (String -> Object)
* @see #getFormatProperties(CellStyle)
*/
private static void setFormatProperties(CellStyle style, Workbook workbook, Map<String, Object> properties) {
style.setAlignment(getHorizontalAlignment(properties, ALIGNMENT));
style.setVerticalAlignment(getVerticalAlignment(properties, VERTICAL_ALIGNMENT));
style.setBorderBottom(getBorderStyle(properties, BORDER_BOTTOM));
style.setBorderLeft(getBorderStyle(properties, BORDER_LEFT));
style.setBorderRight(getBorderStyle(properties, BORDER_RIGHT));
style.setBorderTop(getBorderStyle(properties, BORDER_TOP));
style.setBottomBorderColor(getShort(properties, BOTTOM_BORDER_COLOR));
style.setDataFormat(getShort(properties, DATA_FORMAT));
style.setFillPattern(getFillPattern(properties, FILL_PATTERN));
style.setFillForegroundColor(getShort(properties, FILL_FOREGROUND_COLOR));
style.setFillBackgroundColor(getShort(properties, FILL_BACKGROUND_COLOR));
style.setFont(workbook.getFontAt(getInt(properties, FONT)));
style.setHidden(getBoolean(properties, HIDDEN));
style.setIndention(getShort(properties, INDENTION));
style.setLeftBorderColor(getShort(properties, LEFT_BORDER_COLOR));
style.setLocked(getBoolean(properties, LOCKED));
style.setRightBorderColor(getShort(properties, RIGHT_BORDER_COLOR));
style.setRotation(getShort(properties, ROTATION));
style.setTopBorderColor(getShort(properties, TOP_BORDER_COLOR));
style.setWrapText(getBoolean(properties, WRAP_TEXT));
}
代码示例来源:origin: stackoverflow.com
private static CellStyle createBorderedStyle(Workbook wb) {
CellStyle style = wb.createCellStyle();
style.setBorderRight(CellStyle.BORDER_THIN);
style.setRightBorderColor(IndexedColors.BLACK.getIndex());
style.setBorderBottom(CellStyle.BORDER_THIN);
style.setBottomBorderColor(IndexedColors.BLACK.getIndex());
style.setBorderLeft(CellStyle.BORDER_THIN);
style.setLeftBorderColor(IndexedColors.BLACK.getIndex());
style.setBorderTop(CellStyle.BORDER_THIN);
style.setTopBorderColor(IndexedColors.BLACK.getIndex());
return style;
}
代码示例来源:origin: pentaho/pentaho-reporting
@Test
public void testXls_BackgroundStyle() {
when( workbook.createCellStyle() ).thenReturn( xlsStyle );
ExcelCellStyleBuilder builder = new ExcelCellStyleBuilder( workbook );
CellBackground bg = getBackground();
HSSFCellStyleProducer.HSSFCellStyleKey styleKey = getXlsKey();
builder.xls_backgroundStyle( bg, styleKey );
verify( xlsStyle, times( 1 ) ).setBorderBottom( eq( BorderStyle.MEDIUM_DASH_DOT ) );
verify( xlsStyle, times( 1 ) ).setBottomBorderColor( eq( (short) 116 ) );
verify( xlsStyle, times( 1 ) ).setBorderTop( eq( BorderStyle.MEDIUM_DASHED ) );
verify( xlsStyle, times( 1 ) ).setTopBorderColor( eq( (short) 118 ) );
verify( xlsStyle, times( 1 ) ).setBorderLeft( eq( BorderStyle.MEDIUM_DASH_DOT_DOT ) );
verify( xlsStyle, times( 1 ) ).setLeftBorderColor( eq( (short) 120 ) );
verify( xlsStyle, times( 1 ) ).setBorderRight( eq( BorderStyle.MEDIUM ) );
verify( xlsStyle, times( 1 ) ).setRightBorderColor( eq( (short) 122 ) );
verify( xlsStyle, times( 1 ) ).setFillForegroundColor( eq( (short) 123 ) );
verify( xlsStyle, times( 1 ) ).setFillPattern( eq( FillPatternType.SOLID_FOREGROUND ) );
}
代码示例来源:origin: stackoverflow.com
// Create a cell and put a value in it.
Cell cell = row.createCell(1);
cell.setCellValue(4);
// Style the cell with borders all around.
CellStyle style = wb.createCellStyle();
style.setBorderBottom(CellStyle.BORDER_THIN);
style.setBottomBorderColor(IndexedColors.BLACK.getIndex());
style.setBorderLeft(CellStyle.BORDER_THIN);
style.setLeftBorderColor(IndexedColors.GREEN.getIndex());
style.setBorderRight(CellStyle.BORDER_THIN);
style.setRightBorderColor(IndexedColors.BLUE.getIndex());
style.setBorderTop(CellStyle.BORDER_MEDIUM_DASHED);
style.setTopBorderColor(IndexedColors.BLACK.getIndex());
cell.setCellStyle(style);
代码示例来源:origin: cn.bestwu.simpleframework/simpleframework-web
@NotNull
private CellStyle createBorderCellStyle(String styleName) {
CellStyle style = workbook.createCellStyle();
style.cloneStyleFrom(styles.get(styleName));
style.setBorderRight(BorderStyle.THIN);
style.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
style.setBorderLeft(BorderStyle.THIN);
style.setLeftBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
style.setBorderTop(BorderStyle.THIN);
style.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
style.setBorderBottom(BorderStyle.THIN);
style.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
return style;
}
代码示例来源:origin: stackoverflow.com
CellStyle backgroundStyle = workbook.createCellStyle();
backgroundStyle.setFillBackgroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
backgroundStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
backgroundStyle.setBorderBottom(CellStyle.BORDER_THIN);
backgroundStyle.setBottomBorderColor(IndexedColors.BLACK.getIndex());
backgroundStyle.setBorderLeft(CellStyle.BORDER_THIN);
backgroundStyle.setLeftBorderColor(IndexedColors.BLACK.getIndex());
backgroundStyle.setBorderRight(CellStyle.BORDER_THIN);
backgroundStyle.setRightBorderColor(IndexedColors.BLACK.getIndex());
backgroundStyle.setBorderTop(CellStyle.BORDER_THIN);
backgroundStyle.setTopBorderColor(IndexedColors.BLACK.getIndex());
代码示例来源:origin: org.apache.poi/poi-examples
public static void main(String[] args) throws IOException {
try (Workbook wb = new XSSFWorkbook()) { //or new HSSFWorkbook();
Sheet sheet = wb.createSheet("borders");
// Create a row and put some cells in it. Rows are 0 based.
Row row = sheet.createRow((short) 1);
// Create a cell and put a value in it.
Cell cell = row.createCell((short) 1);
cell.setCellValue(4);
// Style the cell with borders all around.
CellStyle style = wb.createCellStyle();
style.setBorderBottom(BorderStyle.THIN);
style.setBottomBorderColor(IndexedColors.BLACK.getIndex());
style.setBorderLeft(BorderStyle.THIN);
style.setLeftBorderColor(IndexedColors.GREEN.getIndex());
style.setBorderRight(BorderStyle.THIN);
style.setRightBorderColor(IndexedColors.BLUE.getIndex());
style.setBorderTop(BorderStyle.MEDIUM_DASHED);
style.setTopBorderColor(IndexedColors.BLACK.getIndex());
cell.setCellStyle(style);
// Write the output to a file
try (FileOutputStream fileOut = new FileOutputStream("xssf-borders.xlsx")) {
wb.write(fileOut);
}
}
}
}
代码示例来源:origin: cn.hutool/hutool-all
/**
* 设置cell的四个边框粗细和颜色
*
* @param cellStyle {@link CellStyle}
* @param borderSize 边框粗细{@link BorderStyle}枚举
* @param colorIndex 颜色的short值
* @return {@link CellStyle}
*/
public static CellStyle setBorder(CellStyle cellStyle, BorderStyle borderSize, IndexedColors colorIndex) {
cellStyle.setBorderBottom(borderSize);
cellStyle.setBottomBorderColor(colorIndex.index);
cellStyle.setBorderLeft(borderSize);
cellStyle.setLeftBorderColor(colorIndex.index);
cellStyle.setBorderRight(borderSize);
cellStyle.setRightBorderColor(colorIndex.index);
cellStyle.setBorderTop(borderSize);
cellStyle.setTopBorderColor(colorIndex.index);
return cellStyle;
}
代码示例来源:origin: stackoverflow.com
CellStyle backgroundStyle = workbook.createCellStyle();
backgroundStyle.setFillBackgroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
backgroundStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
CellStyle borderStyle = workbook.createCellStyle();
borderStyle.setBorderBottom(CellStyle.BORDER_THIN);
borderStyle.setBottomBorderColor(IndexedColors.BLACK.getIndex());
borderStyle.setBorderLeft(CellStyle.BORDER_THIN);
borderStyle.setLeftBorderColor(IndexedColors.BLACK.getIndex());
borderStyle.setBorderRight(CellStyle.BORDER_THIN);
borderStyle.setRightBorderColor(IndexedColors.BLACK.getIndex());
borderStyle.setBorderTop(CellStyle.BORDER_THIN);
borderStyle.setTopBorderColor(IndexedColors.BLACK.getIndex());
代码示例来源:origin: org.apache.poi/poi-examples
private static CellStyle createBorderedStyle(Workbook wb){
BorderStyle thin = BorderStyle.THIN;
short black = IndexedColors.BLACK.getIndex();
CellStyle style = wb.createCellStyle();
style.setBorderRight(thin);
style.setRightBorderColor(black);
style.setBorderBottom(thin);
style.setBottomBorderColor(black);
style.setBorderLeft(thin);
style.setLeftBorderColor(black);
style.setBorderTop(thin);
style.setTopBorderColor(black);
return style;
}
}
代码示例来源:origin: Appendium/objectlabkit
public CellStyle build(ExcelCell cell) {
Optional<CellStyle> cs = cell.findStyle(hashCode());
if (cs.isPresent()) {
return cs.get();
}
CellStyle cellStyle = cell.cloneStyle(hashCode());
addFontFormat(cell, cellStyle);
if (header) {
cellStyle.setBorderBottom(BorderStyle.THIN);
cellStyle.setBottomBorderColor(IndexedColors.BLACK.getIndex());
cellStyle.setFillForegroundColor(IndexedColors.PALE_BLUE.getIndex());
cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
}
addFormat(cell, cellStyle);
if (backgroundColour != null) {
cellStyle.setFillForegroundColor(backgroundColour.getIndex());
cellStyle.setFillPattern(backgroundFillPatternType != null ? backgroundFillPatternType : FillPatternType.SOLID_FOREGROUND);
}
addAlignment(cellStyle);
return cellStyle;
}
代码示例来源:origin: zerouwar/Octopus
public static void setBorderColor(Workbook workbook, CellStyle cellStyle, Color[] color) {
if (color == null) {
return;
}
if (cellStyle instanceof XSSFCellStyle) {
((XSSFCellStyle) cellStyle).setTopBorderColor(new XSSFColor(color[0]));
((XSSFCellStyle) cellStyle).setRightBorderColor(new XSSFColor(color[1]));
((XSSFCellStyle) cellStyle).setBottomBorderColor(new XSSFColor(color[2]));
((XSSFCellStyle) cellStyle).setLeftBorderColor(new XSSFColor(color[3]));
} else if (cellStyle instanceof HSSFCellStyle && workbook instanceof HSSFWorkbook) {
cellStyle.setTopBorderColor(getSimilarColor((HSSFWorkbook) workbook, color[0]).getIndex());
cellStyle.setRightBorderColor(getSimilarColor((HSSFWorkbook) workbook, color[1]).getIndex());
cellStyle.setBottomBorderColor(getSimilarColor((HSSFWorkbook) workbook, color[2]).getIndex());
cellStyle.setLeftBorderColor(getSimilarColor((HSSFWorkbook) workbook, color[3]).getIndex());
} else {
LOGGER.error("unknown font type");
}
}
代码示例来源:origin: eu.ralph-schuster/csv
/**
* Applies the style to the cell.
* @param style the style to be set from this description
*/
public void applyStyle(CellStyle style) {
if (format != null) style.setDataFormat(format);
if (fgColor != null) {
style.setFillForegroundColor(fgColor);
if (fillPattern != null) style.setFillPattern(fillPattern);
}
if (bgColor != null) style.setFillBackgroundColor(bgColor);
if (font != null) style.setFont(font);
if (alignment != null) style.setAlignment(alignment);
// Borders;
if (topBorderColor != null) style.setTopBorderColor(topBorderColor);
if (leftBorderColor != null) style.setLeftBorderColor(leftBorderColor);
if (rightBorderColor != null) style.setRightBorderColor(rightBorderColor);
if (bottomBorderColor != null) style.setBottomBorderColor(bottomBorderColor);
if (topBorderThickness != null) style.setBorderTop(topBorderThickness);
if (leftBorderThickness != null) style.setBorderLeft(leftBorderThickness);
if (rightBorderThickness != null) style.setBorderRight(rightBorderThickness);
if (bottomBorderThickness != null) style.setBorderBottom(bottomBorderThickness);
style.setWrapText(isTextWrap());
}
代码示例来源:origin: pentaho/pentaho-reporting
void xls_backgroundStyle( final CellBackground bg, final HSSFCellStyleProducer.HSSFCellStyleKey styleKey ) {
if ( BorderStyle.NONE.equals( bg.getBottom().getBorderStyle() ) == false ) {
hssfCellStyle.setBorderBottom( styleKey.getBorderStrokeBottom() );
hssfCellStyle.setBottomBorderColor( styleKey.getColorBottom() );
}
if ( BorderStyle.NONE.equals( bg.getTop().getBorderStyle() ) == false ) {
hssfCellStyle.setBorderTop( styleKey.getBorderStrokeTop() );
hssfCellStyle.setTopBorderColor( styleKey.getColorTop() );
}
if ( BorderStyle.NONE.equals( bg.getLeft().getBorderStyle() ) == false ) {
hssfCellStyle.setBorderLeft( styleKey.getBorderStrokeLeft() );
hssfCellStyle.setLeftBorderColor( styleKey.getColorLeft() );
}
if ( BorderStyle.NONE.equals( bg.getRight().getBorderStyle() ) == false ) {
hssfCellStyle.setBorderRight( styleKey.getBorderStrokeRight() );
hssfCellStyle.setRightBorderColor( styleKey.getColorRight() );
}
if ( bg.getBackgroundColor() != null ) {
hssfCellStyle.setFillForegroundColor( styleKey.getColor() );
hssfCellStyle.setFillPattern( FillPatternType.SOLID_FOREGROUND );
}
}
代码示例来源:origin: SheetJS/jxls
newStyle.setBorderRight(style.getBorderRight());
newStyle.setBorderTop(style.getBorderTop());
newStyle.setBottomBorderColor(style.getBottomBorderColor());
newStyle.setDataFormat(style.getDataFormat());
newStyle.setFillBackgroundColor(style.getFillBackgroundColor());
代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev
/**
* Sets the format properties of the given style based on the given map.
*
* @param style cell style
* @param workbook parent workbook
* @param properties map of format properties (String -> Object)
* @see #getFormatProperties(CellStyle)
*/
private static void setFormatProperties(CellStyle style, Workbook workbook, Map<String, Object> properties) {
style.setAlignment(getShort(properties, ALIGNMENT));
style.setBorderBottom(getShort(properties, BORDER_BOTTOM));
style.setBorderLeft(getShort(properties, BORDER_LEFT));
style.setBorderRight(getShort(properties, BORDER_RIGHT));
style.setBorderTop(getShort(properties, BORDER_TOP));
style.setBottomBorderColor(getShort(properties, BOTTOM_BORDER_COLOR));
style.setDataFormat(getShort(properties, DATA_FORMAT));
style.setFillBackgroundColor(getShort(properties, FILL_BACKGROUND_COLOR));
style.setFillForegroundColor(getShort(properties, FILL_FOREGROUND_COLOR));
style.setFillPattern(getShort(properties, FILL_PATTERN));
style.setFont(workbook.getFontAt(getShort(properties, FONT)));
style.setHidden(getBoolean(properties, HIDDEN));
style.setIndention(getShort(properties, INDENTION));
style.setLeftBorderColor(getShort(properties, LEFT_BORDER_COLOR));
style.setLocked(getBoolean(properties, LOCKED));
style.setRightBorderColor(getShort(properties, RIGHT_BORDER_COLOR));
style.setRotation(getShort(properties, ROTATION));
style.setTopBorderColor(getShort(properties, TOP_BORDER_COLOR));
style.setVerticalAlignment(getShort(properties, VERTICAL_ALIGNMENT));
style.setWrapText(getBoolean(properties, WRAP_TEXT));
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi
/**
* Sets the format properties of the given style based on the given map.
*
* @param style cell style
* @param workbook parent workbook
* @param properties map of format properties (String -> Object)
* @see #getFormatProperties(CellStyle)
*/
private static void setFormatProperties(CellStyle style, Workbook workbook, Map<String, Object> properties) {
style.setAlignment(getHorizontalAlignment(properties, ALIGNMENT));
style.setVerticalAlignment(getVerticalAlignment(properties, VERTICAL_ALIGNMENT));
style.setBorderBottom(getBorderStyle(properties, BORDER_BOTTOM));
style.setBorderLeft(getBorderStyle(properties, BORDER_LEFT));
style.setBorderRight(getBorderStyle(properties, BORDER_RIGHT));
style.setBorderTop(getBorderStyle(properties, BORDER_TOP));
style.setBottomBorderColor(getShort(properties, BOTTOM_BORDER_COLOR));
style.setDataFormat(getShort(properties, DATA_FORMAT));
style.setFillPattern(getFillPattern(properties, FILL_PATTERN));
style.setFillForegroundColor(getShort(properties, FILL_FOREGROUND_COLOR));
style.setFillBackgroundColor(getShort(properties, FILL_BACKGROUND_COLOR));
style.setFont(workbook.getFontAt(getInt(properties, FONT)));
style.setHidden(getBoolean(properties, HIDDEN));
style.setIndention(getShort(properties, INDENTION));
style.setLeftBorderColor(getShort(properties, LEFT_BORDER_COLOR));
style.setLocked(getBoolean(properties, LOCKED));
style.setRightBorderColor(getShort(properties, RIGHT_BORDER_COLOR));
style.setRotation(getShort(properties, ROTATION));
style.setTopBorderColor(getShort(properties, TOP_BORDER_COLOR));
style.setWrapText(getBoolean(properties, WRAP_TEXT));
}
代码示例来源:origin: com.eas.platypus/platypus-js-reports
private void copyStyle(Workbook workbook, Cell fromCell, Cell toCell) {
CellStyle toStyle = toCell.getCellStyle();
CellStyle fromStyle = fromCell.getCellStyle();
CellStyle newStyle = workbook.createCellStyle();
newStyle.setAlignment(fromStyle.getAlignment());
newStyle.setBorderBottom(fromStyle.getBorderBottom());
newStyle.setBorderLeft(fromStyle.getBorderLeft());
newStyle.setBorderRight(fromStyle.getBorderRight());
newStyle.setBorderTop(fromStyle.getBorderTop());
newStyle.setBottomBorderColor(fromStyle.getBottomBorderColor());
newStyle.setFillBackgroundColor(fromStyle.getFillBackgroundColor());
newStyle.setFillForegroundColor(fromStyle.getFillForegroundColor());
newStyle.setFillPattern(fromStyle.getFillPattern());
newStyle.setFont(workbook.getFontAt(fromStyle.getFontIndex()));
newStyle.setHidden(fromStyle.getHidden());
newStyle.setIndention(fromStyle.getIndention());
newStyle.setLeftBorderColor(fromStyle.getLeftBorderColor());
newStyle.setLocked(fromStyle.getLocked());
newStyle.setRightBorderColor(fromStyle.getRightBorderColor());
newStyle.setTopBorderColor(fromStyle.getTopBorderColor());
newStyle.setVerticalAlignment(fromStyle.getVerticalAlignment());
newStyle.setWrapText(fromStyle.getWrapText());
newStyle.setDataFormat(toStyle.getDataFormat());
toCell.setCellStyle(newStyle);
}
}
内容来源于网络,如有侵权,请联系作者删除!