[]
        
(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>
Specifies how a background image is laid out within the destination rectangle.

Use this enum with IRange.setBackgroundImageLayout(BackgroundImageLayout) to control how a range's background image is displayed. Supported layouts can stretch the image, center it, fit it while preserving its aspect ratio, or place it at the top-left corner without resizing. The default layout returned by IRange.getBackgroundImageLayout() is 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
      Specifies to resize the image to fill the destination dimensions. The aspect ratio is not preserved.
    • Center

      public static final BackgroundImageLayout Center
      Specifies to centre-align the image within the destination rectangle.
    • Zoom

      public static final BackgroundImageLayout Zoom
      Specifies to resize the image to fit in the destination dimensions while preserving the image’s native aspect ratio.
    • None

      public static final BackgroundImageLayout None
      Specifies to left-align the image at the top across the destination rectangle.
  • 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()
      Retrieves the integer value representing the enum constant.

      This method returns the ordinal value of the current BackgroundImageLayout constant.

      Returns:
      The ordinal value of the enum constant.
    • forValue

      public static BackgroundImageLayout forValue(Integer value)
      Retrieves the enum constant corresponding to the specified integer value.

      Use this method to convert an integer value returned by getValue() back to its corresponding BackgroundImageLayout constant.

      Parameters:
      value - The integer value representing the enum constant.
      Returns:
      The BackgroundImageLayout enum constant corresponding to the specified value.
      Throws:
      NullPointerException - if value is null.
      ArrayIndexOutOfBoundsException - if value does not correspond to a valid enum constant.