[]
        
首页
开发者学堂
文档
论坛
市场
生态机会
活动
立即试用
(Showing Draft Content)

BackgroundImageLayout

Enum Class BackgroundImageLayout

java.lang.Object
java.lang.Enum<BackgroundImageLayout>
com.grapecity.documents.excel.BackgroundImageLayout
All Implemented Interfaces:
Serializable, Comparable<BackgroundImageLayout>, Constable

public enum BackgroundImageLayout extends Enum<BackgroundImageLayout>
指定背景图像在目标矩形区域中的布局方式。

该枚举与 IRange.setBackgroundImageLayout(BackgroundImageLayout)配合使用,用于控制区域背景图像的显示方式。支持的布局方式包括:拉伸图像、居中图像、在保留纵横比的同时适应区域大小,或将图像放置在左上角且不进行缩放。IRange.getBackgroundImageLayout() 返回的默认布局为 Stretch。


 IRange range = worksheet.getRange("A1:C3");
 byte[] backgroundImage = new byte[] {
     (byte) 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A,
     0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52,
     0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
     0x08, 0x06, 0x00, 0x00, 0x00, 0x1F, 0x15, (byte) 0xC4,
     (byte) 0x89, 0x00, 0x00, 0x00, 0x0A, 0x49, 0x44, 0x41,
     0x54, 0x78, (byte) 0x9C, 0x63, 0x00, 0x01, 0x00, 0x00,
     0x05, 0x00, 0x01, 0x0D, 0x0A, 0x2D, (byte) 0xB4,
     0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44,
     (byte) 0xAE, 0x42, 0x60, (byte) 0x82
 };
 range.setBackgroundImage(backgroundImage);
 range.setBackgroundImageLayout(BackgroundImageLayout.Zoom);
 
  • Enum Constant Details

    • Stretch

      public static final BackgroundImageLayout Stretch
      指定调整图像大小以填充目标尺寸。宽高比不会被保持。
    • Center

      public static final BackgroundImageLayout Center
      指定在目标矩形内将图像居中对齐。
    • Zoom

      public static final BackgroundImageLayout Zoom
      指定调整图像大小以适应目标尺寸,同时保持图像的原始宽高比。
    • None

      public static final BackgroundImageLayout None
      指定将图像左对齐并显示在目标矩形的顶部。
  • Method Details

    • values

      public static BackgroundImageLayout[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static BackgroundImageLayout valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getValue

      public int getValue()
      获取表示枚举常量的整数值。

      此方法返回当前 BackgroundImageLayout 常量的序数值。

      Returns:
      枚举常量的序数值。
    • forValue

      public static BackgroundImageLayout forValue(Integer value)
      获取与指定整数值对应的枚举常量。

      使用此方法可将 getValue() 返回的整数值转换回对应的 BackgroundImageLayout 常量。

      Parameters:
      value - 表示枚举常量的整数值。
      Returns:
      与指定值对应的 BackgroundImageLayout 枚举常量。
      Throws:
      NullPointerException - 如果 value 为 null。
      ArrayIndexOutOfBoundsException - 如果 value 不对应有效的枚举常量。