[]
        
(Showing Draft Content)

ILabelOptions

Interface ILabelOptions


public interface ILabelOptions
Indicates the cell label options.

Use this interface to configure how a watermark label is displayed for a range, including its position, visibility, font, foreground color, and margin. You can access these options from IRange.getLabelOptions() and use LabelAlignment and LabelVisibility to control the label layout. SpreadJS only.


 worksheet.getRange("A1").setValue("Name");
 worksheet.getRange("A1").setWatermark("Required");
 ILabelOptions labelOptions = worksheet.getRange("A1").getLabelOptions();
 labelOptions.setAlignment(LabelAlignment.topLeft);
 labelOptions.setVisibility(LabelVisibility.visible);
 
  • Method Details

    • getAlignment

      LabelAlignment getAlignment()
      Gets the watermark label alignment in the cell.

      This property controls where the watermark label is displayed within the cell. The returned value is one of the LabelAlignment constants. If no position has been set, this method returns LabelAlignment.topLeft. SpreadJS only.

      
       IRange range = worksheet.getRange("A1");
       range.setWatermark("Required");
       range.getLabelOptions().setAlignment(LabelAlignment.bottomCenter);
       LabelAlignment alignment = range.getLabelOptions().getAlignment();
       
      Returns:
      The watermark label alignment in the cell.
    • setAlignment

      void setAlignment(LabelAlignment alignment)
      Sets the watermark label alignment in the cell.

      Use LabelAlignment to place the watermark label at the top or bottom of the cell, with left, center, or right alignment.

      
       IRange range = worksheet.getRange("A1");
       range.setWatermark("Required");
       range.getLabelOptions().setAlignment(LabelAlignment.bottomCenter);
       
      Parameters:
      alignment - The watermark label alignment in the cell.
    • getVisibility

      LabelVisibility getVisibility()
      Gets the visibility mode of the watermark label.

      The returned value is one of the LabelVisibility constants. If no visibility has been set, this method returns LabelVisibility.auto. SpreadJS only.

      
       IRange range = worksheet.getRange("A1");
       range.setWatermark("Required");
       range.getLabelOptions().setVisibility(LabelVisibility.visible);
       LabelVisibility visibility = range.getLabelOptions().getVisibility();
       
      Returns:
      The visibility mode of the watermark label.
    • setVisibility

      void setVisibility(LabelVisibility visibility)
      Sets the visibility mode of the watermark label.

      Use LabelVisibility.visible to always show the watermark in the padding area, LabelVisibility.hidden to show it in the cell area based on the cell value, or LabelVisibility.auto to switch between the two behaviors automatically. SpreadJS only.

      
       IRange range = worksheet.getRange("A1");
       range.setWatermark("Required");
       range.getLabelOptions().setVisibility(LabelVisibility.visible);
       
      Parameters:
      visibility - The visibility mode of the watermark label.
    • getForeColor

      Color getForeColor()
      Gets the foreground color of the watermark label for the range.

      This property returns the foreground color applied to the watermark label for the range. SpreadJS only.

      
       IRange range = worksheet.getRange("A1");
       range.setWatermark("Required");
       range.getLabelOptions().setForeColor(Color.GetRed());
       Color color = range.getLabelOptions().getForeColor();
       
      Returns:
      The foreground color of the watermark label for the range.
    • setForeColor

      void setForeColor(Color color)
      Sets the foreground color of the watermark label for the range.

      Use this property to set the foreground color applied to the watermark label for the range.

      
       IRange range = worksheet.getRange("A1");
       range.setWatermark("Required");
       range.getLabelOptions().setForeColor(Color.GetRed());
       
      Parameters:
      color - The foreground color of the watermark label for the range.
    • getFont

      IFont getFont()
      Returns an instance of IFont which may be used to get and set font properties of the watermark represented by this IRange.

      Use the returned font object to configure the watermark label font for the range, such as its bold style, italic style, size, and color. SpreadJS only.

      
       IRange range = worksheet.getRange("A1");
       range.setWatermark("Required");
       IFont font = range.getLabelOptions().getFont();
       font.setBold(true);
       font.setColor(Color.GetBlue());
       
      Returns:
      The IFont object that defines the watermark font properties for this range.
    • getMargin

      Margin getMargin()
      Gets the margin of the watermark label for the range.

      This property returns the watermark label margin in pixels relative to the cell. The returned Margin defines the top, right, bottom, and left spacing used for the watermark label. Returns null if no margin has been set. SpreadJS only.

      
       IRange range = worksheet.getRange("A1");
       range.setWatermark("Required");
       range.getLabelOptions().setMargin(new Margin(2, 4, 2, 4));
       Margin margin = range.getLabelOptions().getMargin();
       int right = margin.getRight();
       
      Returns:
      The margin of the watermark label for the range, or null if no margin has been set.
    • setMargin

      void setMargin(Margin margin)
      Sets the margin of the watermark label for the range.

      The margin is specified by a Margin object in pixels relative to the cell.

      
       IRange range = worksheet.getRange("A1");
       range.setWatermark("Required");
       range.getLabelOptions().setMargin(new Margin(15, 0, 0, 0));
       Margin margin = range.getLabelOptions().getMargin();
       
      Parameters:
      margin - The watermark label margin in pixels relative to the cell.