@Test public void testXlsx_BackgroundStyle() { when( workbook.createCellStyle() ).thenReturn( xlsxStyle ); ExcelCellStyleBuilder builder = new ExcelCellStyleBuilder( workbook ); CellBackground bg = getBackground(); HSSFCellStyleProducer.HSSFCellStyleKey styleKey = getXlsxKey(); builder.withBackgroundStyle( bg, styleKey ); verify( xlsxStyle, times( 1 ) ).setBorderBottom( eq( BorderStyle.DASH_DOT ) ); verify( xlsxStyle, times( 1 ) ) .setBorderColor( eq( XSSFCellBorder.BorderSide.BOTTOM ), notNull( XSSFColor.class ) ); verify( xlsxStyle, times( 1 ) ).setBorderTop( eq( BorderStyle.DOTTED ) ); verify( xlsxStyle, times( 1 ) ).setBorderColor( eq( XSSFCellBorder.BorderSide.TOP ), notNull( XSSFColor.class ) ); verify( xlsxStyle, times( 1 ) ).setBorderLeft( eq( BorderStyle.DASH_DOT_DOT ) ); verify( xlsxStyle, times( 1 ) ).setBorderColor( eq( XSSFCellBorder.BorderSide.LEFT ), notNull( XSSFColor.class ) ); verify( xlsxStyle, times( 1 ) ).setBorderRight( eq( BorderStyle.DASHED ) ); verify( xlsxStyle, times( 1 ) ).setBorderColor( eq( XSSFCellBorder.BorderSide.RIGHT ), notNull( XSSFColor.class ) ); verify( xlsxStyle, times( 1 ) ).setFillForegroundColor( notNull( XSSFColor.class ) ); verify( xlsxStyle, times( 1 ) ).setFillPattern( eq( FillPatternType.SOLID_FOREGROUND ) ); }
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 ); } }
ExcelCellStyleBuilder { 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 ); } } }
ExcelCellStyleBuilder { 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 ); } } ExcelCellStyleBuilder( Workbook workbook ); }
ExcelCellStyleBuilder { 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 ); } } ExcelCellStyleBuilder( Workbook workbook ); void withRotation( final StyleSheet element ); void withElementStyle( final StyleSheet elementStyleSheet, final HSSFCellStyleProducer.HSSFCellStyleKey styleKey ); void withBackgroundStyle( final CellBackground bg, final HSSFCellStyleProducer.HSSFCellStyleKey styleKey ); CellStyle build(); }
ExcelCellStyleBuilder { 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 ); } } ExcelCellStyleBuilder( Workbook workbook ); void withRotation( final StyleSheet element ); void withElementStyle( final StyleSheet elementStyleSheet, final HSSFCellStyleProducer.HSSFCellStyleKey styleKey ); void withBackgroundStyle( final CellBackground bg, final HSSFCellStyleProducer.HSSFCellStyleKey styleKey ); CellStyle build();  }