[]
        
首页
开发者学堂
文档
论坛
市场
生态机会
活动
立即试用
(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
表示单元格装饰图标。

使用此类可以创建一个图标,并通过 CellDecoration 将其添加到单元格装饰中。该图标由源字符串(通常是 SVG 或图像的数据 URI)、以像素为单位的尺寸,以及由 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)
      创建一个新的DecorationIcon类实例。
      Parameters:
      src - 图标的内容字符串。
      width - 图标的宽度(以像素为单位)。
      height - 图标的高度(以像素为单位)。
      position - 图标的位置。
  • Method Details

    • getSrc

      public String getSrc()
      获取图标 src 字符串。
      
       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:
      图标 src 字符串。
    • getWidth

      public int getWidth()
      获取图标的宽度,以像素为单位。
      
       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:
      图标的宽度,以像素为单位。
    • getHeight

      public int getHeight()
      获取图标的高度,以像素为单位。
      
       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:
      图标的高度,以像素为单位。
    • getPosition

      public IconPosition getPosition()
      获取图标位置。
      
       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:
      图标位置。