org.apache.poi.ss.usermodel.CellStyle.setRotation()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(11.6k)|赞(0)|评价(0)|浏览(334)

本文整理了Java中org.apache.poi.ss.usermodel.CellStyle.setRotation()方法的一些代码示例,展示了CellStyle.setRotation()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CellStyle.setRotation()方法的具体详情如下:
包路径:org.apache.poi.ss.usermodel.CellStyle
类名称:CellStyle
方法名:setRotation

CellStyle.setRotation介绍

[英]set the degree of rotation for the text in the cell
[中]设置单元格中文本的旋转度

代码示例

代码示例来源:origin: org.apache.poi/poi

  1. /**
  2. * Sets the format properties of the given style based on the given map.
  3. *
  4. * @param style cell style
  5. * @param workbook parent workbook
  6. * @param properties map of format properties (String -> Object)
  7. * @see #getFormatProperties(CellStyle)
  8. */
  9. private static void setFormatProperties(CellStyle style, Workbook workbook, Map<String, Object> properties) {
  10. style.setAlignment(getHorizontalAlignment(properties, ALIGNMENT));
  11. style.setVerticalAlignment(getVerticalAlignment(properties, VERTICAL_ALIGNMENT));
  12. style.setBorderBottom(getBorderStyle(properties, BORDER_BOTTOM));
  13. style.setBorderLeft(getBorderStyle(properties, BORDER_LEFT));
  14. style.setBorderRight(getBorderStyle(properties, BORDER_RIGHT));
  15. style.setBorderTop(getBorderStyle(properties, BORDER_TOP));
  16. style.setBottomBorderColor(getShort(properties, BOTTOM_BORDER_COLOR));
  17. style.setDataFormat(getShort(properties, DATA_FORMAT));
  18. style.setFillPattern(getFillPattern(properties, FILL_PATTERN));
  19. style.setFillForegroundColor(getShort(properties, FILL_FOREGROUND_COLOR));
  20. style.setFillBackgroundColor(getShort(properties, FILL_BACKGROUND_COLOR));
  21. style.setFont(workbook.getFontAt(getInt(properties, FONT)));
  22. style.setHidden(getBoolean(properties, HIDDEN));
  23. style.setIndention(getShort(properties, INDENTION));
  24. style.setLeftBorderColor(getShort(properties, LEFT_BORDER_COLOR));
  25. style.setLocked(getBoolean(properties, LOCKED));
  26. style.setRightBorderColor(getShort(properties, RIGHT_BORDER_COLOR));
  27. style.setRotation(getShort(properties, ROTATION));
  28. style.setTopBorderColor(getShort(properties, TOP_BORDER_COLOR));
  29. style.setWrapText(getBoolean(properties, WRAP_TEXT));
  30. }

代码示例来源:origin: Vatavuk/excel-io

  1. @Override
  2. public void accept(final CellStyle style) {
  3. style.setRotation(this.value);
  4. }
  5. }

代码示例来源:origin: stackoverflow.com

  1. CellStyle styleVertical = wb.createCellStyle();
  2. styleVertical.setRotation(0xff);

代码示例来源:origin: stackoverflow.com

  1. CellStyle cssVertical = wb.createCellStyle();
  2. cssVertical.setFont(f);
  3. cssVertical.setRotation((short)90);

代码示例来源:origin: pentaho/pentaho-reporting

  1. public void withRotation( final StyleSheet element ) {
  2. if ( element == null ) {
  3. return;
  4. }
  5. Object raw = element.getStyleProperty( TextStyleKeys.TEXT_ROTATION, null );
  6. if ( raw == null ) {
  7. return;
  8. }
  9. TextRotation rotation = TextRotation.class.cast( raw );
  10. if ( isXLSX ) {
  11. //xlsx has different rotation degree boundaries
  12. final short numericValue = rotation.getNumericValue();
  13. hssfCellStyle.setRotation( numericValue < 0 ? (short) ( 90 - numericValue ) : numericValue );
  14. } else {
  15. hssfCellStyle.setRotation( rotation.getNumericValue() );
  16. }
  17. }

代码示例来源:origin: pentaho/pentaho-reporting

  1. @Test
  2. public void testRotationXLSX() {
  3. when( workbook.createCellStyle() ).thenReturn( xlsStyle );
  4. ExcelCellStyleBuilder builder = new ExcelCellStyleBuilder( workbook );
  5. StyleSheet element = mock( StyleSheet.class );
  6. when( element.getStyleProperty( eq( TextStyleKeys.TEXT_ROTATION ), any() ) ).thenReturn( TextRotation.D_90 );
  7. builder.withRotation( element );
  8. builder.build();
  9. verify( xlsStyle, times( 1 ) ).setRotation( eq( (short) 90 ) );
  10. when( element.getStyleProperty( eq( TextStyleKeys.TEXT_ROTATION ), any() ) ).thenReturn( TextRotation.D_270 );
  11. builder.withRotation( element );
  12. builder.build();
  13. verify( xlsStyle, times( 1 ) ).setRotation( eq( (short) -90 ) );
  14. }

代码示例来源:origin: pentaho/pentaho-reporting

  1. @Test
  2. public void testNullRotation() {
  3. when( workbook.createCellStyle() ).thenReturn( xlsStyle );
  4. ExcelCellStyleBuilder builder = new ExcelCellStyleBuilder( workbook );
  5. builder.withRotation( null );
  6. builder.build();
  7. verify( xlsStyle, times( 0 ) ).setRotation( anyShort() );
  8. }

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

  1. /**
  2. * Sets the format properties of the given style based on the given map.
  3. *
  4. * @param style cell style
  5. * @param workbook parent workbook
  6. * @param properties map of format properties (String -> Object)
  7. * @see #getFormatProperties(CellStyle)
  8. */
  9. private static void setFormatProperties(CellStyle style, Workbook workbook, Map<String, Object> properties) {
  10. style.setAlignment(getHorizontalAlignment(properties, ALIGNMENT));
  11. style.setVerticalAlignment(getVerticalAlignment(properties, VERTICAL_ALIGNMENT));
  12. style.setBorderBottom(getBorderStyle(properties, BORDER_BOTTOM));
  13. style.setBorderLeft(getBorderStyle(properties, BORDER_LEFT));
  14. style.setBorderRight(getBorderStyle(properties, BORDER_RIGHT));
  15. style.setBorderTop(getBorderStyle(properties, BORDER_TOP));
  16. style.setBottomBorderColor(getShort(properties, BOTTOM_BORDER_COLOR));
  17. style.setDataFormat(getShort(properties, DATA_FORMAT));
  18. style.setFillPattern(getFillPattern(properties, FILL_PATTERN));
  19. style.setFillForegroundColor(getShort(properties, FILL_FOREGROUND_COLOR));
  20. style.setFillBackgroundColor(getShort(properties, FILL_BACKGROUND_COLOR));
  21. style.setFont(workbook.getFontAt(getInt(properties, FONT)));
  22. style.setHidden(getBoolean(properties, HIDDEN));
  23. style.setIndention(getShort(properties, INDENTION));
  24. style.setLeftBorderColor(getShort(properties, LEFT_BORDER_COLOR));
  25. style.setLocked(getBoolean(properties, LOCKED));
  26. style.setRightBorderColor(getShort(properties, RIGHT_BORDER_COLOR));
  27. style.setRotation(getShort(properties, ROTATION));
  28. style.setTopBorderColor(getShort(properties, TOP_BORDER_COLOR));
  29. style.setWrapText(getBoolean(properties, WRAP_TEXT));
  30. }

代码示例来源:origin: com.haulmont.thirdparty/poi

  1. /**
  2. * Sets the format properties of the given style based on the given map.
  3. *
  4. * @param style cell style
  5. * @param workbook parent workbook
  6. * @param properties map of format properties (String -> Object)
  7. * @see #getFormatProperties(CellStyle)
  8. */
  9. private static void setFormatProperties(CellStyle style, Workbook workbook, Map<String, Object> properties) {
  10. style.setAlignment(getShort(properties, ALIGNMENT));
  11. style.setBorderBottom(getShort(properties, BORDER_BOTTOM));
  12. style.setBorderLeft(getShort(properties, BORDER_LEFT));
  13. style.setBorderRight(getShort(properties, BORDER_RIGHT));
  14. style.setBorderTop(getShort(properties, BORDER_TOP));
  15. style.setBottomBorderColor(getShort(properties, BOTTOM_BORDER_COLOR));
  16. style.setDataFormat(getShort(properties, DATA_FORMAT));
  17. style.setFillBackgroundColor(getShort(properties, FILL_BACKGROUND_COLOR));
  18. style.setFillForegroundColor(getShort(properties, FILL_FOREGROUND_COLOR));
  19. style.setFillPattern(getShort(properties, FILL_PATTERN));
  20. style.setFont(workbook.getFontAt(getShort(properties, FONT)));
  21. style.setHidden(getBoolean(properties, HIDDEN));
  22. style.setIndention(getShort(properties, INDENTION));
  23. style.setLeftBorderColor(getShort(properties, LEFT_BORDER_COLOR));
  24. style.setLocked(getBoolean(properties, LOCKED));
  25. style.setRightBorderColor(getShort(properties, RIGHT_BORDER_COLOR));
  26. style.setRotation(getShort(properties, ROTATION));
  27. style.setTopBorderColor(getShort(properties, TOP_BORDER_COLOR));
  28. style.setVerticalAlignment(getShort(properties, VERTICAL_ALIGNMENT));
  29. style.setWrapText(getBoolean(properties, WRAP_TEXT));
  30. }

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

  1. /**
  2. * Sets the format properties of the given style based on the given map.
  3. *
  4. * @param style cell style
  5. * @param workbook parent workbook
  6. * @param properties map of format properties (String -> Object)
  7. * @see #getFormatProperties(CellStyle)
  8. */
  9. private static void setFormatProperties(CellStyle style, Workbook workbook, Map<String, Object> properties) {
  10. style.setAlignment(getShort(properties, ALIGNMENT));
  11. style.setBorderBottom(getShort(properties, BORDER_BOTTOM));
  12. style.setBorderLeft(getShort(properties, BORDER_LEFT));
  13. style.setBorderRight(getShort(properties, BORDER_RIGHT));
  14. style.setBorderTop(getShort(properties, BORDER_TOP));
  15. style.setBottomBorderColor(getShort(properties, BOTTOM_BORDER_COLOR));
  16. style.setDataFormat(getShort(properties, DATA_FORMAT));
  17. style.setFillBackgroundColor(getShort(properties, FILL_BACKGROUND_COLOR));
  18. style.setFillForegroundColor(getShort(properties, FILL_FOREGROUND_COLOR));
  19. style.setFillPattern(getShort(properties, FILL_PATTERN));
  20. style.setFont(workbook.getFontAt(getShort(properties, FONT)));
  21. style.setHidden(getBoolean(properties, HIDDEN));
  22. style.setIndention(getShort(properties, INDENTION));
  23. style.setLeftBorderColor(getShort(properties, LEFT_BORDER_COLOR));
  24. style.setLocked(getBoolean(properties, LOCKED));
  25. style.setRightBorderColor(getShort(properties, RIGHT_BORDER_COLOR));
  26. style.setRotation(getShort(properties, ROTATION));
  27. style.setTopBorderColor(getShort(properties, TOP_BORDER_COLOR));
  28. style.setVerticalAlignment(getShort(properties, VERTICAL_ALIGNMENT));
  29. style.setWrapText(getBoolean(properties, WRAP_TEXT));
  30. }

代码示例来源:origin: org.apache.poi/poi-contrib

  1. /**
  2. * Sets the format properties of the given style based on the given map.
  3. *
  4. * @param style cell style
  5. * @param workbook parent workbook
  6. * @param properties map of format properties (String -> Object)
  7. * @see #getFormatProperties(CellStyle)
  8. */
  9. private static void setFormatProperties(CellStyle style, Workbook workbook, Map<String, Object> properties) {
  10. style.setAlignment(getShort(properties, ALIGNMENT));
  11. style.setBorderBottom(getShort(properties, BORDER_BOTTOM));
  12. style.setBorderLeft(getShort(properties, BORDER_LEFT));
  13. style.setBorderRight(getShort(properties, BORDER_RIGHT));
  14. style.setBorderTop(getShort(properties, BORDER_TOP));
  15. style.setBottomBorderColor(getShort(properties, BOTTOM_BORDER_COLOR));
  16. style.setDataFormat(getShort(properties, DATA_FORMAT));
  17. style.setFillBackgroundColor(getShort(properties, FILL_BACKGROUND_COLOR));
  18. style.setFillForegroundColor(getShort(properties, FILL_FOREGROUND_COLOR));
  19. style.setFillPattern(getShort(properties, FILL_PATTERN));
  20. style.setFont(workbook.getFontAt(getShort(properties, FONT)));
  21. style.setHidden(getBoolean(properties, HIDDEN));
  22. style.setIndention(getShort(properties, INDENTION));
  23. style.setLeftBorderColor(getShort(properties, LEFT_BORDER_COLOR));
  24. style.setLocked(getBoolean(properties, LOCKED));
  25. style.setRightBorderColor(getShort(properties, RIGHT_BORDER_COLOR));
  26. style.setRotation(getShort(properties, ROTATION));
  27. style.setTopBorderColor(getShort(properties, TOP_BORDER_COLOR));
  28. style.setVerticalAlignment(getShort(properties, VERTICAL_ALIGNMENT));
  29. style.setWrapText(getBoolean(properties, WRAP_TEXT));
  30. }

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

  1. /**
  2. * Sets the format properties of the given style based on the given map.
  3. *
  4. * @param style cell style
  5. * @param workbook parent workbook
  6. * @param properties map of format properties (String -> Object)
  7. * @see #getFormatProperties(CellStyle)
  8. */
  9. private static void setFormatProperties(CellStyle style, Workbook workbook, Map<String, Object> properties) {
  10. style.setAlignment(getShort(properties, ALIGNMENT));
  11. style.setBorderBottom(getShort(properties, BORDER_BOTTOM));
  12. style.setBorderLeft(getShort(properties, BORDER_LEFT));
  13. style.setBorderRight(getShort(properties, BORDER_RIGHT));
  14. style.setBorderTop(getShort(properties, BORDER_TOP));
  15. style.setBottomBorderColor(getShort(properties, BOTTOM_BORDER_COLOR));
  16. style.setDataFormat(getShort(properties, DATA_FORMAT));
  17. style.setFillBackgroundColor(getShort(properties, FILL_BACKGROUND_COLOR));
  18. style.setFillForegroundColor(getShort(properties, FILL_FOREGROUND_COLOR));
  19. style.setFillPattern(getShort(properties, FILL_PATTERN));
  20. style.setFont(workbook.getFontAt(getShort(properties, FONT)));
  21. style.setHidden(getBoolean(properties, HIDDEN));
  22. style.setIndention(getShort(properties, INDENTION));
  23. style.setLeftBorderColor(getShort(properties, LEFT_BORDER_COLOR));
  24. style.setLocked(getBoolean(properties, LOCKED));
  25. style.setRightBorderColor(getShort(properties, RIGHT_BORDER_COLOR));
  26. style.setRotation(getShort(properties, ROTATION));
  27. style.setTopBorderColor(getShort(properties, TOP_BORDER_COLOR));
  28. style.setVerticalAlignment(getShort(properties, VERTICAL_ALIGNMENT));
  29. style.setWrapText(getBoolean(properties, WRAP_TEXT));
  30. }

代码示例来源:origin: com.github.nic-luo/rober-office

  1. toStyle.setRotation(fromStyle.getRotation()); //旋转
  2. toStyle.setVerticalAlignment(fromStyle.getVerticalAlignment());
  3. toStyle.setWrapText(fromStyle.getWrapText());

相关文章