[]
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);
getFont()IFont which may be used to get and set font properties of the watermark represented by this IRange.voidsetAlignment(LabelAlignment alignment) voidsetForeColor(Color color) voidvoidsetVisibility(LabelVisibility visibility) 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();
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);
alignment - The watermark label alignment in the cell.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();
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);
visibility - The visibility mode of the watermark label.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();
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());
color - The foreground color of the watermark label for the range.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());
IFont object that defines the watermark font properties for this 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();
null if no margin has been set.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();
margin - The watermark label margin in pixels relative to the cell.