[]
        
(Showing Draft Content)

IFillFormat

Interface IFillFormat


public interface IFillFormat
Represents fill formatting for a shape or chart element.

Use this interface to inspect and modify fill settings such as solid color, pattern, gradient, texture, transparency, and visibility for a drawing object. Instances of this interface are typically obtained from a public formatting API such as IShape.getFill().


 IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
 IFillFormat fillFormat = shape.getFill();
 fillFormat.solid();
 fillFormat.getColor().setRGB(Color.GetBlue());
 
  • Method Details

    • getPatternColor

      IColorFormat getPatternColor()
      Returns the IColorFormat object that represents the specified pattern color.

      Use this property to read or modify the foreground color used by a pattern fill. To apply a pattern fill first, use patterned(PatternType).

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
       IFillFormat fillFormat = shape.getFill();
       fillFormat.patterned(PatternType.LightDownwardDiagonal);
       IColorFormat patternColor = fillFormat.getPatternColor();
       patternColor.setRGB(Color.GetBlue());
       
      Returns:
      The IColorFormat object that represents the pattern color.
    • getColor

      IColorFormat getColor()
      Gets the IColorFormat object that represents the specified foreground fill or solid color.

      Use the returned IColorFormat to inspect or modify the color used by the current fill.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
       IFillFormat fillFormat = shape.getFill();
       fillFormat.solid();
       IColorFormat color = fillFormat.getColor();
       color.setRGB(Color.GetBlue());
       
      Returns:
      The IColorFormat object that represents the foreground fill or solid color.
    • getVisible

      boolean getVisible()
      Gets whether the object is visible.

      Use this method to determine whether the fill for the shape is currently displayed.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
       IFillFormat fillFormat = shape.getFill();
       fillFormat.solid();
       fillFormat.setVisible(false);
       boolean visible = fillFormat.getVisible();
       
      Returns:
      true if the object is visible; otherwise, false.
    • setVisible

      void setVisible(boolean value)
      Sets whether the object is visible.

      Use this method to show or hide the fill for the shape.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
       IFillFormat fillFormat = shape.getFill();
       fillFormat.solid();
       fillFormat.setVisible(false);
       
      Parameters:
      value - true if the object is visible; otherwise, false.
    • getGradientAngle

      double getGradientAngle()
      Gets the angle of the gradient fill for the specified fill format.

      Use this method to get the direction of a gradient that has been applied to the fill.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
       IFillFormat fillFormat = shape.getFill();
       fillFormat.twoColorGradient(GradientStyle.Horizontal, 1);
       fillFormat.setGradientAngle(45);
       double angle = fillFormat.getGradientAngle();
       
      Returns:
      The angle of the gradient fill for the specified fill format.
    • setGradientAngle

      void setGradientAngle(double value)
      Sets the angle of the gradient fill for the specified fill format.

      Use this method to set the direction of a gradient that has been applied to the fill.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
       IFillFormat fillFormat = shape.getFill();
       fillFormat.twoColorGradient(GradientStyle.Horizontal, 1);
       fillFormat.setGradientAngle(45);
       
      Parameters:
      value - The angle of the gradient fill for the specified fill format.
    • getGradientPathType

      PathShapeType getGradientPathType()
      Gets the path type for the gradient fill.

      Use this method to determine which path-based gradient shape is applied to the fill. For radial, rectangular, or path gradients, set the value with setGradientPathType(PathShapeType) before reading it back.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
       IFillFormat fillFormat = shape.getFill();
       fillFormat.twoColorGradient(GradientStyle.FromCenter, 1);
       fillFormat.setGradientPathType(PathShapeType.Radial);
       PathShapeType pathType = fillFormat.getGradientPathType();
       
      Returns:
      The path type for the gradient fill.
    • setGradientPathType

      void setGradientPathType(PathShapeType value)
      Sets the path type for the gradient fill.

      Use this method after configuring a gradient fill to change how the gradient is applied to the shape, such as a linear, radial, rectangular, or path-based fill.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
       IFillFormat fillFormat = shape.getFill();
       fillFormat.twoColorGradient(GradientStyle.FromCenter, 1);
       fillFormat.setGradientPathType(PathShapeType.Radial);
       
      Parameters:
      value - The path shape type for the gradient fill.
    • getGradientDegree

      double getGradientDegree()
      Returns the gradient degree of the specified one-color shaded fill as a floating-point value from 0.0 (dark) through 1.0 (light).

      Use this property to retrieve the shading intensity that was applied by oneColorGradient(GradientStyle,int,double).

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
       IFillFormat fillFormat = shape.getFill();
       fillFormat.oneColorGradient(GradientStyle.DiagonalDown, 2, 0.5);
       double degree = fillFormat.getGradientDegree();
       
      Returns:
      The gradient degree for the one-color shaded fill, from 0.0 (dark)through 1.0 (light).
    • getGradientStops

      IGradientStops getGradientStops()
      Gets the collection of gradient stops for the gradient fill.

      Use the returned IGradientStops collection to inspect or modify the colors and positions that define the gradient.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
       IFillFormat fillFormat = shape.getFill();
       fillFormat.twoColorGradient(GradientStyle.Horizontal, 1);
       IGradientStops gradientStops = fillFormat.getGradientStops();
       gradientStops.get(0).getColor().setRGB(Color.GetBlue());
       
      Returns:
      The IGradientStops collection for the gradient fill, or null if the fill does not define gradient stops.
    • getGradientStyle

      GradientStyle getGradientStyle()
      Returns the gradient style for the specified fill.

      Use this property to retrieve the GradientStyle that was applied by gradient fill methods such as oneColorGradient(GradientStyle,int,double) and twoColorGradient(GradientStyle,int).

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
       IFillFormat fillFormat = shape.getFill();
       fillFormat.twoColorGradient(GradientStyle.FromCenter, 1);
       GradientStyle style = fillFormat.getGradientStyle();
       
      Returns:
      The GradientStyle for the fill.
    • getGradientVariant

      int getGradientVariant()
      Returns the shade variant for the specified fill as an integer value from 1 through 4.

      The returned value corresponds to the gradient variant used by the current fill settings.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
       IFillFormat fillFormat = shape.getFill();
       fillFormat.twoColorGradient(GradientStyle.Horizontal, 3);
       int variant = fillFormat.getGradientVariant();
       
      Returns:
      The shade variant for the specified fill as an integer value from 1 through 4.
    • getPattern

      PatternType getPattern()
      Returns the fill pattern.

      Use this method to retrieve the PatternType applied to the shape's fill after the fill has been configured as a pattern fill.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
       IFillFormat fillFormat = shape.getFill();
       fillFormat.patterned(PatternType.Percent10);
       PatternType pattern = fillFormat.getPattern();
       
      Returns:
      The PatternType used by the fill.
    • getPresetGradientType

      PresetGradientType getPresetGradientType()
      Returns the preset gradient type for the specified fill.

      Use this method to retrieve the PresetGradientType that is applied after calling presetGradient(GradientStyle,int,PresetGradientType).

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
       IFillFormat fillFormat = shape.getFill();
       fillFormat.presetGradient(GradientStyle.Vertical, 4, PresetGradientType.CalmWater);
       PresetGradientType gradientType = fillFormat.getPresetGradientType();
       
      Returns:
      The preset gradient type for the fill.
    • getPresetTexture

      PresetTexture getPresetTexture()
      Returns the preset texture for the specified fill.

      Use this method to get the PresetTexture currently applied to a texture fill set by presetTextured(PresetTexture).

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
       IFillFormat fillFormat = shape.getFill();
       fillFormat.presetTextured(PresetTexture.Canvas);
       PresetTexture texture = fillFormat.getPresetTexture();
       
      Returns:
      The preset texture for the specified fill.
    • getRotateWithObject

      boolean getRotateWithObject()
      Gets if the fill style should rotate with the object.

      This property indicates whether the current fill style follows the object's rotation.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
       IFillFormat fillFormat = shape.getFill();
       fillFormat.twoColorGradient(GradientStyle.Horizontal, 1);
       fillFormat.setRotateWithObject(false);
       boolean rotateWithObject = fillFormat.getRotateWithObject();
       
      Returns:
      true if the fill style rotates with the object; otherwise, false.
    • setRotateWithObject

      void setRotateWithObject(boolean value)
      Sets if the fill style should rotate with the object.

      This property indicates whether the current fill style follows the object's rotation.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
       IFillFormat fillFormat = shape.getFill();
       fillFormat.twoColorGradient(GradientStyle.Horizontal, 1);
       fillFormat.setRotateWithObject(false);
       
      Parameters:
      value - true if the fill style rotates with the object; otherwise, false.
    • getTextureAlignment

      TextureAlignment getTextureAlignment()
      Gets the alignment of the texture fill for the specified IFillFormat.

      This property specifies the origin of the coordinate grid used to tile the texture fill.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
       IFillFormat fillFormat = shape.getFill();
       fillFormat.presetTextured(PresetTexture.Canvas);
       fillFormat.setTextureAlignment(TextureAlignment.Center);
       TextureAlignment alignment = fillFormat.getTextureAlignment();
       
      Returns:
      The texture fill alignment.
    • setTextureAlignment

      void setTextureAlignment(TextureAlignment value)
      Sets the alignment of the texture fill for the specified IFillFormat.

      Use this method to control how the texture is aligned within the fill area.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
       IFillFormat fillFormat = shape.getFill();
       fillFormat.presetTextured(PresetTexture.Canvas);
       fillFormat.setTextureAlignment(TextureAlignment.Center);
       
      Parameters:
      value - The texture alignment to apply.
    • getTextureHorizontalScale

      double getTextureHorizontalScale()
      Gets the value for horizontally scaling the text for the IFillFormat.

      Use this property to retrieve the horizontal scale applied to the current texture fill.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
       IFillFormat fillFormat = shape.getFill();
       fillFormat.presetTextured(PresetTexture.Canvas);
       fillFormat.setTextureHorizontalScale(1.5);
       double scale = fillFormat.getTextureHorizontalScale();
       
      Returns:
      The horizontal scale value for the texture fill.
    • setTextureHorizontalScale

      void setTextureHorizontalScale(double value)
      Sets the value for horizontally scaling the texture for the IFillFormat.

      Use this property to set the horizontal scale applied to the current texture fill.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
       IFillFormat fillFormat = shape.getFill();
       fillFormat.presetTextured(PresetTexture.Canvas);
       fillFormat.setTextureHorizontalScale(1.5);
       
      Parameters:
      value - The horizontal scale value for the texture fill.
    • getTextureOffsetX

      double getTextureOffsetX()
      Returns the offset X value for the specified fill.

      Use this property to retrieve the horizontal tile offset applied to the current texture fill. If this value is not set on the current fill and a parent fill exists, the inherited value is returned.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
       IFillFormat fillFormat = shape.getFill();
       fillFormat.presetTextured(PresetTexture.Canvas);
       fillFormat.setTextureOffsetX(12.0);
       double offsetX = fillFormat.getTextureOffsetX();
       
      Returns:
      The horizontal offset value for the texture fill.
    • setTextureOffsetX

      void setTextureOffsetX(double value)
      Sets the offset X value for the specified fill.

      Use this property to set the horizontal tile offset applied to the current texture fill. If this value is not set on the current fill and a parent fill exists, the inherited value is returned.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
       IFillFormat fillFormat = shape.getFill();
       fillFormat.presetTextured(PresetTexture.Canvas);
       fillFormat.setTextureOffsetX(12.0);
       
      Parameters:
      value - The horizontal offset value for the texture fill.
    • getTextureOffsetY

      double getTextureOffsetY()
      Returns the offset Y value for the specified fill.

      Use this property to get the vertical offset applied to a texture fill layout.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
       IFillFormat fillFormat = shape.getFill();
       fillFormat.presetTextured(PresetTexture.Canvas);
       fillFormat.setTextureOffsetY(3.2);
       double offsetY = fillFormat.getTextureOffsetY();
       
      Returns:
      The offset Y value for the specified fill.
    • setTextureOffsetY

      void setTextureOffsetY(double value)
      Sets the offset Y value for the specified fill.

      Use this property to set the vertical offset applied to a texture fill layout.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
       IFillFormat fillFormat = shape.getFill();
       fillFormat.presetTextured(PresetTexture.Canvas);
       fillFormat.setTextureOffsetY(3.2);
       
      Parameters:
      value - The offset Y value for the specified fill.
    • getTextureVerticalScale

      double getTextureVerticalScale()
      Returns the texture vertical scale for the specified fill.

      Use this property to get the vertical scale applied to the current texture fill.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
       IFillFormat fillFormat = shape.getFill();
       fillFormat.presetTextured(PresetTexture.Canvas);
       fillFormat.setTextureVerticalScale(0.8);
       double scale = fillFormat.getTextureVerticalScale();
       
      Returns:
      The vertical scale value for the texture fill.
    • setTextureVerticalScale

      void setTextureVerticalScale(double value)
      Sets the texture vertical scale for the specified fill.

      Use this property to set the vertical scale applied to the current texture fill.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
       IFillFormat fillFormat = shape.getFill();
       fillFormat.presetTextured(PresetTexture.Canvas);
       fillFormat.setTextureVerticalScale(0.8);
       
      Parameters:
      value - The vertical scale value for the texture fill.
    • getTransparency

      double getTransparency()
      Gets the degree of transparency of the specified fill as a value from 0.0 (opaque) through 1.0 (clear).
      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
       IFillFormat fillFormat = shape.getFill();
       fillFormat.solid();
       fillFormat.setTransparency(0.25);
       double transparency = fillFormat.getTransparency();
       
      Returns:
      The degree of transparency of the fill, from 0.0 for a fully opaque fill to 1.0 for a fully clear fill.
    • setTransparency

      void setTransparency(double value)
      Sets the degree of transparency of the specified fill as a value from 0.0 (opaque) through 1.0 (clear).
      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
       IFillFormat fillFormat = shape.getFill();
       fillFormat.solid();
       fillFormat.setTransparency(0.25);
       
      Parameters:
      value - The degree of transparency of the fill, from 0.0 for a fully opaque fill to 1.0 for a fully clear fill.
    • getType

      FillType getType()
      Returns the fill type.

      Use this method to determine which kind of fill is currently applied to the object, such as solid, patterned, gradient, textured, picture, or group fill.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
       IFillFormat fillFormat = shape.getFill();
       fillFormat.solid();
       FillType fillType = fillFormat.getType();
       
      Returns:
      The current fill type.
    • oneColorGradient

      void oneColorGradient(GradientStyle style, int variant, double degree)
      Sets the specified fill to a one-color gradient.

      Use this method to apply a gradient that varies a single color from dark to light. The variant value can be from 1 through 4, corresponding to one of the four variants on the Gradient tab in the Fill Effects dialog box. If style is GradientStyle.FromCenter, variant can only be 1 or 2.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
       IFillFormat fillFormat = shape.getFill();
       fillFormat.oneColorGradient(GradientStyle.Horizontal, 1, 0.5);
       double degree = fillFormat.getGradientDegree();
       
      Parameters:
      style - The GradientStyle to apply.
      variant - The gradient variant. Can be a value from 1 through 4, corresponding to one of the four variants on the Gradient tab in the Fill Effects dialog box. If GradientStyle.FromCenter is used, the value can only be 1 or 2.
      degree - The gradient degree. Can be a value from 0.0 (dark) through 1.0(light).
    • patterned

      void patterned(PatternType pattern)
      Sets the specified fill to a pattern.

      Use this method to apply a PatternType fill to a shape. After the pattern is set, you can customize the background color and pattern color through getColor() and getPatternColor().

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
       IFillFormat fillFormat = shape.getFill();
       fillFormat.patterned(PatternType.LightDownwardDiagonal);
       fillFormat.getColor().setRGB(Color.GetRed());
       fillFormat.getPatternColor().setRGB(Color.GetBlue());
       
      Parameters:
      pattern - The PatternType object.
    • presetGradient

      void presetGradient(GradientStyle style, int variant, PresetGradientType presetGradientType)
      Sets the specified fill to a preset gradient.

      Use this method to apply one of the built-in gradient presets to a shape fill.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
       IFillFormat fillFormat = shape.getFill();
       fillFormat.presetGradient(GradientStyle.Vertical, 4, PresetGradientType.CalmWater);
       PresetGradientType gradientType = fillFormat.getPresetGradientType();
       
      Parameters:
      style - The GradientStyle object to be set.
      variant - The gradient variant. Can be a value from 1 through 4, corresponding to one of the four variants on the Gradient tab in the Fill Effects dialog box. If style is GradientStyle.FromCenter, variant can only be 1 or 2.
      presetGradientType - The PresetGradientType object.
    • presetTextured

      void presetTextured(PresetTexture presetTexture)
      Sets the specified fill format to a preset texture.

      Use this method to apply one of the built-in PresetTexture values to a shape fill. After applying the texture, you can further adjust the texture layout by using methods such as setTextureAlignment(TextureAlignment).

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
       IFillFormat fillFormat = shape.getFill();
       fillFormat.presetTextured(PresetTexture.Canvas);
       fillFormat.setTextureAlignment(TextureAlignment.Center);
       
      Parameters:
      presetTexture - The PresetTexture to apply. Must not be null.
    • solid

      void solid()
      Sets the specified fill to a uniform color.

      After calling this method, use getColor() to configure the solid fill color.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
       IFillFormat fillFormat = shape.getFill();
       fillFormat.solid();
       fillFormat.getColor().setRGB(Color.GetBlue());
       
    • twoColorGradient

      void twoColorGradient(GradientStyle style, int variant)
      Sets the specified fill to a two-color gradient.

      Use this method to apply a gradient fill that blends between two colors. After calling this method, configure the gradient colors through the fill's color settings.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
       IFillFormat fillFormat = shape.getFill();
       fillFormat.twoColorGradient(GradientStyle.Horizontal, 1);
       fillFormat.getColor().setRGB(Color.GetBlue());
       
      Parameters:
      style - The GradientStyle to apply.
      variant - The gradient variant. Can be a value from 1 through 4, corresponding to one of the four variants on the Gradient tab in the Fill Effects dialog box. If style is GradientStyle.FromCenter, the value can only be 1 or 2.
    • userPicture

      void userPicture(String fileName) throws IOException
      Fills the specified shape with an image.

      Use this method to apply an image file as the fill for a shape. To fill the shape with small tiles of an image, use userTextured(String).

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
       IFillFormat fillFormat = shape.getFill();
       try {
           String imagePath = java.nio.file.Paths.get("Users", "DefaultApps", "Documents", "logo.png").toString();
           fillFormat.userPicture(imagePath);
       } catch (Exception e) {
           throw new IllegalStateException("Unable to use shape fill picture from file", e);
       }
       
      Parameters:
      fileName - The name of the picture file.
      Throws:
      IOException - if the picture file cannot be read.
    • userPicture

      void userPicture(InputStream stream, ImageType type) throws IOException
      Fills the specified shape with an image.

      Use this method to apply a picture fill from an InputStream. Specify the image format with the ImageType parameter.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
       IFillFormat fillFormat = shape.getFill();
       try (InputStream stream = createSampleImageStream()) {
           fillFormat.userPicture(stream, ImageType.PNG);
       } catch (IOException e) {
           throw new IllegalStateException("Unable to use shape fill picture from stream", e);
       }
       
      Parameters:
      stream - The stream of the picture file.
      type - The ImageType of the stream.
      Throws:
      IOException - if an I/O error occurs while reading the image stream.
    • userTextured

      void userTextured(String fileName) throws IOException
      Fills the specified shape with small tiles of an image.

      Use this method to apply a texture fill from an image file. The image is tiled across the shape instead of being stretched as a single picture.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
       IFillFormat fillFormat = shape.getFill();
       try {
            String imagePath = java.nio.file.Paths.get("Users", "DefaultApps", "Documents", "logo.png").toString();
            fillFormat.userTextured(imagePath);
       } catch (IOException e) {
           throw new IllegalStateException("Unable to apply shape texture from file", e);
       }
       
      Parameters:
      fileName - The name of the picture file.
      Throws:
      IOException - if the picture file cannot be read.
    • userTextured

      void userTextured(InputStream stream, ImageType type)
      Fills the specified shape with small tiles of an image.

      Use this method to apply a texture fill from an image stream. The type parameter specifies the ImageType of the image data in the stream.

      
       IShape shape = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 20, 20, 100, 60);
       IFillFormat fillFormat = shape.getFill();
       byte[] imageData = new byte[] {(byte) 137, 80, 78, 71, 13, 10, 26, 10};
       try (InputStream stream = new ByteArrayInputStream(imageData)) {
           fillFormat.userTextured(stream, ImageType.PNG);
       } catch (Exception e) {
           throw new IllegalStateException("Unable to apply shape texture from stream", e);
       }
       
      Parameters:
      stream - The stream of the picture file.
      type - The ImageType of the stream.