@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 ) ); }
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 ); } }
ExcelCellStyleBuilder { 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 ); } } }
ExcelCellStyleBuilder { 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 ); } } ExcelCellStyleBuilder( Workbook workbook ); }
ExcelCellStyleBuilder { 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 ); } } 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 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 ); } } 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();  }