[]
        
(Showing Draft Content)

CellDecorationIcon

Class CellDecorationIcon

java.lang.Object
com.grapecity.documents.excel.CellDecorationIcon
All Implemented Interfaces:
ICellDecorationIcon

public class CellDecorationIcon extends Object implements ICellDecorationIcon
Represents a cell decoration icon.

Use this class to create an icon that can be added to a cell's decoration via CellDecoration. The icon is defined by a source string (typically a data URI for an SVG or image), dimensions in pixels, and a position relative to the cell specified by IconPosition.


 CellDecorationIcon icon = new CellDecorationIcon(
     "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iMTIiLz4=",
     12, 12, IconPosition.OutsideRight);
 worksheet.getRange("A1").setValue("Hello");
 worksheet.getRange("A1").setDecoration(
     new CellDecoration(null, Collections.singletonList(icon)));
 
  • Constructor Details

    • CellDecorationIcon

      public CellDecorationIcon(String src, int width, int height, IconPosition position)
      Creates a new instance of the DecorationIcon class.
      Parameters:
      src - The icon src string.
      width - The icon width in pixels.
      height - The icon height in pixels.
      position - The icon position.
  • Method Details

    • getSrc

      public String getSrc()
      Gets the icon src string.
      
       CellDecorationIcon icon = new CellDecorationIcon(
           "data:image/svg+xml;base64,PHN2Zz4=", 12, 16, IconPosition.OutsideRight);
       String src = icon.getSrc();
       
      Specified by:
      getSrc in interface ICellDecorationIcon
      Returns:
      The icon src string.
    • getWidth

      public int getWidth()
      Gets the icon width in pixels.
      
       CellDecorationIcon icon = new CellDecorationIcon(
           "data:image/svg+xml;base64,PHN2Zz4=", 12, 16, IconPosition.OutsideRight);
       int width = icon.getWidth();
       
      Specified by:
      getWidth in interface ICellDecorationIcon
      Returns:
      The icon width in pixels.
    • getHeight

      public int getHeight()
      Gets the icon height in pixels.
      
       CellDecorationIcon icon = new CellDecorationIcon(
           "data:image/svg+xml;base64,PHN2Zz4=", 12, 16, IconPosition.OutsideRight);
       int height = icon.getHeight();
       
      Specified by:
      getHeight in interface ICellDecorationIcon
      Returns:
      The icon height in pixels.
    • getPosition

      public IconPosition getPosition()
      Gets the icon position.
      
       CellDecorationIcon icon = new CellDecorationIcon(
           "data:image/svg+xml;base64,PHN2Zz4=", 12, 16, IconPosition.OutsideRight);
       IconPosition position = icon.getPosition();
       
      Specified by:
      getPosition in interface ICellDecorationIcon
      Returns:
      The icon position.