[]
        
(Showing Draft Content)

Margin

Class Margin

java.lang.Object
com.grapecity.documents.excel.Margin

public class Margin extends Object
Represents the watermark margin in pixels relative to a cell.

Use this class to define the top, right, bottom, and left margins applied to a watermark in a range through ILabelOptions.setMargin(Margin). You can create a margin with the same value on all sides or specify each side separately.


 worksheet.getRange("A1").setValue("Draft");
 Margin margin = new Margin(4, 8, 4, 8);
 worksheet.getRange("A1").getLabelOptions().setMargin(margin);
 
  • Constructor Summary

    Constructors
    Constructor
    Description
    Margin(int all)
    Creates a Margin instance that applies the same margin value to all four sides.
    Margin(int top, int right, int bottom, int left)
    Creates a Margin instance with separate values for each side.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Gets the bottom margin.
    int
    Gets the left margin.
    int
    Gets the right margin.
    int
    Gets the top margin.
    Gets the string representation of this margin.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Margin

      public Margin(int all)
      Creates a Margin instance that applies the same margin value to all four sides.

      Use this constructor to define the watermark margin in pixels relative to a cell when the top, right, bottom, and left margins should be identical. The created margin can be applied through ILabelOptions.setMargin(Margin).

      
       worksheet.getRange("A1").setValue("Draft");
       Margin margin = new Margin(4);
       worksheet.getRange("A1").getLabelOptions().setMargin(margin);
       
      Parameters:
      all - The value, in pixels, to set for all margins.
    • Margin

      public Margin(int top, int right, int bottom, int left)
      Creates a Margin instance with separate values for each side.

      Use this constructor to define top, right, bottom, and left watermark margins independently before assigning the margin to label options.

      
       Margin margin = new Margin(10, 20, 10, 20);
       worksheet.getRange("A1").getLabelOptions().setMargin(margin);
       
      Parameters:
      top - The top margin value.
      right - The right margin value.
      bottom - The bottom margin value.
      left - The left margin value.
  • Method Details

    • getLeft

      public int getLeft()
      Gets the left margin.

      The returned value is the left watermark margin, in pixels, relative to the cell.

      
       Margin margin = new Margin(1, 2, 3, 4);
       int left = margin.getLeft();
       
      Returns:
      The left margin value, in pixels.
    • getRight

      public int getRight()
      Gets the right margin.

      The returned value specifies the right watermark margin in pixels relative to the cell.

      
       Margin margin = new Margin(1, 2, 3, 4);
       int right = margin.getRight();
       
      Returns:
      The right margin value in pixels.
    • getTop

      public int getTop()
      Gets the top margin.

      Returns the top margin value in pixels relative to the cell.

      
       Margin margin = new Margin(1, 2, 3, 4);
       int top = margin.getTop();
       
      Returns:
      The top margin value, in pixels relative to the cell.
    • getBottom

      public int getBottom()
      Gets the bottom margin.

      The returned value is the bottom watermark margin, in pixels, relative to the cell.

      
       Margin margin = new Margin(1, 2, 3, 4);
       int bottom = margin.getBottom();
       
      Returns:
      The bottom margin value, in pixels.
    • toString

      public String toString()
      Gets the string representation of this margin.

      The returned string contains the top, right, bottom, and left margin values in that order, separated by spaces. You can pass the returned value to StringToMargin(String) to create a Margin instance with the same margin values.

      Overrides:
      toString in class Object
      Returns:
      A string that represents this margin in top-right-bottom-left order.