Java Code Examples for org.apache.poi.xssf.usermodel.XSSFCellStyle#setBorderColor()

The following examples show how to use org.apache.poi.xssf.usermodel.XSSFCellStyle#setBorderColor() . 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: ExcelCellStyleBuilder.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
void xlsx_backgroundStyle( final CellBackground bg, final HSSFCellStyleProducer.HSSFCellStyleKey styleKey ) {
  final XSSFCellStyle xssfCellStyle = (XSSFCellStyle) hssfCellStyle;
  if ( BorderStyle.NONE.equals( bg.getBottom().getBorderStyle() ) == false ) {
    hssfCellStyle.setBorderBottom( styleKey.getBorderStrokeBottom() );
    xssfCellStyle.setBorderColor( XSSFCellBorder.BorderSide.BOTTOM, new XSSFColor( styleKey.getExtendedColorBottom() ) );
  }
  if ( BorderStyle.NONE.equals( bg.getTop().getBorderStyle() ) == false ) {
    hssfCellStyle.setBorderTop( styleKey.getBorderStrokeTop() );
    xssfCellStyle.setBorderColor( XSSFCellBorder.BorderSide.TOP, new XSSFColor( styleKey.getExtendedColorTop() ) );
  }
  if ( BorderStyle.NONE.equals( bg.getLeft().getBorderStyle() ) == false ) {
    hssfCellStyle.setBorderLeft( styleKey.getBorderStrokeLeft() );
    xssfCellStyle.setBorderColor( XSSFCellBorder.BorderSide.LEFT, new XSSFColor( styleKey.getExtendedColorLeft() ) );
  }
  if ( BorderStyle.NONE.equals( bg.getRight().getBorderStyle() ) == false ) {
    hssfCellStyle.setBorderRight( styleKey.getBorderStrokeRight() );
    xssfCellStyle.setBorderColor( XSSFCellBorder.BorderSide.RIGHT, new XSSFColor( styleKey.getExtendedColorRight() ) );
  }
  if ( bg.getBackgroundColor() != null ) {
    xssfCellStyle.setFillForegroundColor( new XSSFColor( styleKey.getExtendedColor() ) );
    hssfCellStyle.setFillPattern( FillPatternType.SOLID_FOREGROUND );
  }
}
 
Example 2
Source File: ExcelUtils.java    From mySpringBoot with Apache License 2.0 5 votes vote down vote up
/**
 * 设置边框
 *
 * @param style
 * @param border
 * @param color
 */
private static void setBorder(XSSFCellStyle style, BorderStyle border, XSSFColor color) {
    style.setBorderTop(border);
    style.setBorderLeft(border);
    style.setBorderRight(border);
    style.setBorderBottom(border);
    style.setBorderColor(BorderSide.TOP, color);
    style.setBorderColor(BorderSide.LEFT, color);
    style.setBorderColor(BorderSide.RIGHT, color);
    style.setBorderColor(BorderSide.BOTTOM, color);
}