@Test public void testElementStyleSet() { when( workbook.createCellStyle() ).thenReturn( xlsStyle ); ExcelCellStyleBuilder builder = new ExcelCellStyleBuilder( workbook ); when( workbook.createCellStyle() ).thenReturn( xlsStyle ); when( styleKey.getHorizontalAlignment() ).thenReturn( HorizontalAlignment.CENTER ); when( styleKey.getVerticalAlignment() ).thenReturn( VerticalAlignment.CENTER ); when( styleKey.isWrapText() ).thenReturn( true ); when( workbook.getFontAt( anyShort() ) ).thenReturn( font ); when( styleKey.getIndention() ).thenReturn( (short) 15 ); when( styleKey.getDataStyle() ).thenReturn( (short) -1 ); builder.withElementStyle( mock( StyleSheet.class ), styleKey ); verify( xlsStyle, times( 1 ) ).setAlignment( eq( HorizontalAlignment.CENTER ) ); verify( xlsStyle, times( 1 ) ).setVerticalAlignment( eq( VerticalAlignment.CENTER ) ); verify( xlsStyle, times( 1 ) ).setFont( any() ); verify( xlsStyle, times( 1 ) ).setWrapText( eq( true ) ); verify( xlsStyle, times( 1 ) ).setIndention( eq( (short) 15 ) ); verify( xlsStyle, times( 0 ) ).setDataFormat( anyShort() ); }
public void withElementStyle( final StyleSheet elementStyleSheet, final HSSFCellStyleProducer.HSSFCellStyleKey styleKey ) { if ( elementStyleSheet == null ) { return; } hssfCellStyle.setAlignment( styleKey.getHorizontalAlignment() ); hssfCellStyle.setVerticalAlignment( styleKey.getVerticalAlignment() ); hssfCellStyle.setFont( workbook.getFontAt( styleKey.getFont() ) ); hssfCellStyle.setWrapText( styleKey.isWrapText() ); hssfCellStyle.setIndention( styleKey.getIndention() ); if ( styleKey.getDataStyle() >= 0 ) { hssfCellStyle.setDataFormat( styleKey.getDataStyle() ); } }
ExcelCellStyleBuilder { public void withElementStyle( final StyleSheet elementStyleSheet, final HSSFCellStyleProducer.HSSFCellStyleKey styleKey ) { if ( elementStyleSheet == null ) { return; } hssfCellStyle.setAlignment( styleKey.getHorizontalAlignment() ); hssfCellStyle.setVerticalAlignment( styleKey.getVerticalAlignment() ); hssfCellStyle.setFont( workbook.getFontAt( styleKey.getFont() ) ); hssfCellStyle.setWrapText( styleKey.isWrapText() ); hssfCellStyle.setIndention( styleKey.getIndention() ); if ( styleKey.getDataStyle() >= 0 ) { hssfCellStyle.setDataFormat( styleKey.getDataStyle() ); } } }
ExcelCellStyleBuilder { public void withElementStyle( final StyleSheet elementStyleSheet, final HSSFCellStyleProducer.HSSFCellStyleKey styleKey ) { if ( elementStyleSheet == null ) { return; } hssfCellStyle.setAlignment( styleKey.getHorizontalAlignment() ); hssfCellStyle.setVerticalAlignment( styleKey.getVerticalAlignment() ); hssfCellStyle.setFont( workbook.getFontAt( styleKey.getFont() ) ); hssfCellStyle.setWrapText( styleKey.isWrapText() ); hssfCellStyle.setIndention( styleKey.getIndention() ); if ( styleKey.getDataStyle() >= 0 ) { hssfCellStyle.setDataFormat( styleKey.getDataStyle() ); } } ExcelCellStyleBuilder( Workbook workbook ); }
ExcelCellStyleBuilder { public void withElementStyle( final StyleSheet elementStyleSheet, final HSSFCellStyleProducer.HSSFCellStyleKey styleKey ) { if ( elementStyleSheet == null ) { return; } hssfCellStyle.setAlignment( styleKey.getHorizontalAlignment() ); hssfCellStyle.setVerticalAlignment( styleKey.getVerticalAlignment() ); hssfCellStyle.setFont( workbook.getFontAt( styleKey.getFont() ) ); hssfCellStyle.setWrapText( styleKey.isWrapText() ); hssfCellStyle.setIndention( styleKey.getIndention() ); if ( styleKey.getDataStyle() >= 0 ) { hssfCellStyle.setDataFormat( styleKey.getDataStyle() ); } } 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 { public void withElementStyle( final StyleSheet elementStyleSheet, final HSSFCellStyleProducer.HSSFCellStyleKey styleKey ) { if ( elementStyleSheet == null ) { return; } hssfCellStyle.setAlignment( styleKey.getHorizontalAlignment() ); hssfCellStyle.setVerticalAlignment( styleKey.getVerticalAlignment() ); hssfCellStyle.setFont( workbook.getFontAt( styleKey.getFont() ) ); hssfCellStyle.setWrapText( styleKey.isWrapText() ); hssfCellStyle.setIndention( styleKey.getIndention() ); if ( styleKey.getDataStyle() >= 0 ) { hssfCellStyle.setDataFormat( styleKey.getDataStyle() ); } } 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();  }