[]
        
(Showing Draft Content)

IBorders

Interface IBorders


public interface IBorders
Represents a collection of border objects for a range or style.

Use this interface to apply common border settings, such as line style and color, to the outer and inside borders of the collection. Use get(BordersIndex) to access a specific edge, inside, or diagonal border.


 IRange range = worksheet.getRange("B2:E6");
 IBorders borders = range.getBorders();
 borders.setLineStyle(BorderLineStyle.DashDot);
 borders.setColor(Color.GetGreen());

 borders.get(BordersIndex.EdgeTop).setColor(Color.GetRed());
 borders.get(BordersIndex.InsideHorizontal).setLineStyle(BorderLineStyle.Double);
 
  • Method Details

    • getColor

      Color getColor()
      Gets the Color object applied to the border collection.

      Use this method when you want to retrieve a fixed color. To use a color that follows the workbook theme, use getThemeColor() or setThemeColor(ThemeColor). To work with a specific border, use get(BordersIndex).

      
       IBorders borders = worksheet.getRange("B2:E6").getBorders();
       borders.setLineStyle(BorderLineStyle.DashDot);
       borders.setColor(Color.GetRed());
      
       Color color = borders.getColor();
       
      Returns:
      The Color object applied to the border collection.
    • setColor

      void setColor(Color value)
      Sets the Color object applied to the border collection.

      Use this method when you want to apply a fixed color. To apply a color that follows the workbook theme, use getThemeColor() or setThemeColor(ThemeColor). To work with a specific border, use get(BordersIndex).

      
       IBorders borders = worksheet.getRange("B2:E6").getBorders();
       borders.setLineStyle(BorderLineStyle.DashDot);
       borders.setColor(Color.GetRed());
       
      Parameters:
      value - The Color object to apply to the border collection.
    • getColorIndex

      int getColorIndex()
      Gets the color index applied to the border collection.

      The value can be a palette color index or one of the special values defined by ColorDataIndex, such as ColorDataIndex.Automatic or ColorDataIndex.None. To work with a specific border, use get(BordersIndex).

      
       IBorders borders = worksheet.getRange("B2:E6").getBorders();
       borders.setLineStyle(BorderLineStyle.DashDot);
      
       borders.setColorIndex(ColorDataIndex.Automatic.getValue());
      
       ColorDataIndex colorIndex = ColorDataIndex.forValue(borders.getColorIndex());
       
      Returns:
      The color index applied to the border collection.
    • setColorIndex

      void setColorIndex(int value)
      Sets the color index applied to the border collection.

      The value can be a palette color index or one of the special values defined by ColorDataIndex, such as ColorDataIndex.Automatic or ColorDataIndex.None. To work with a specific border, use get(BordersIndex).

      
       IBorders borders = worksheet.getRange("B2:E6").getBorders();
       borders.setLineStyle(BorderLineStyle.DashDot);
      
       borders.setColorIndex(ColorDataIndex.Automatic.getValue());
       
      Parameters:
      value - The color index to apply to the border collection.
    • getThemeColor

      ThemeColor getThemeColor()
      Gets the ThemeColor value applied to the border collection.

      Use this method to retrieve a workbook theme color instead of a fixed Color. If the borders do not use a theme color, this method returns ThemeColor.None.

      
       IBorders borders = worksheet.getRange("B2:E6").getBorders();
       borders.setLineStyle(BorderLineStyle.DashDot);
      
       borders.setThemeColor(ThemeColor.Accent2);
      
       ThemeColor themeColor = borders.getThemeColor();
       
      Returns:
      The ThemeColor value applied to the border collection, or ThemeColor.None if the borders do not use a theme color.
    • setThemeColor

      void setThemeColor(ThemeColor value)
      Sets the ThemeColor value applied to the border collection.

      Use this method to apply a workbook theme color instead of a fixed Color.

      
       IBorders borders = worksheet.getRange("B2:E6").getBorders();
       borders.setLineStyle(BorderLineStyle.DashDot);
      
       borders.setThemeColor(ThemeColor.Accent2);
       
      Parameters:
      value - The ThemeColor value to apply to the border collection.
    • getTintAndShade

      double getTintAndShade()
      Gets the tint and shade value applied to the border collection color.

      The value ranges from -1 (darkest) to 1 (lightest), and 0 is neutral. The default value is 0.

      
       IBorders borders = worksheet.getRange("B2:E6").getBorders();
       borders.setLineStyle(BorderLineStyle.DashDot);
       borders.setThemeColor(ThemeColor.Accent2);
      
       borders.setTintAndShade(0.5);
      
       double tintAndShade = borders.getTintAndShade();
       
      Returns:
      The tint and shade value applied to the border collection color.
    • setTintAndShade

      void setTintAndShade(double value)
      Sets the tint and shade value applied to the border collection color.

      The value ranges from -1 (darkest) to 1 (lightest), and 0 is neutral. The default value is 0.

      
       IBorders borders = worksheet.getRange("B2:E6").getBorders();
       borders.setLineStyle(BorderLineStyle.DashDot);
       borders.setThemeColor(ThemeColor.Accent2);
      
       borders.setTintAndShade(0.5);
       
      Parameters:
      value - The tint and shade value to apply, from -1 (darkest) to 1 (lightest); 0 is neutral.
    • getLineStyle

      BorderLineStyle getLineStyle()
      Gets the line style applied to the border collection.
      
       IBorders borders = worksheet.getRange("B2:E6").getBorders();
       borders.setLineStyle(BorderLineStyle.DashDot);
      
       BorderLineStyle lineStyle = borders.getLineStyle();
       
      Returns:
      The BorderLineStyle value applied to the border collection.
    • setLineStyle

      void setLineStyle(BorderLineStyle value)
      Sets the line style applied to the border collection.

      This method applies the specified BorderLineStyle to the outer and inside borders in the collection. To set a diagonal border, use get(BordersIndex) with BordersIndex.DiagonalDown or BordersIndex.DiagonalUp.

      
       IBorders borders = worksheet.getRange("B2:E6").getBorders();
       borders.setLineStyle(BorderLineStyle.DashDot);
       
      Parameters:
      value - The border line style to apply to the border collection.
    • getCount

      int getCount()
      Gets the number of border objects in the collection.

      For a normal range border collection, this value is 6, representing the four edge borders and the two inside borders.

      
       IBorders borders = worksheet.getRange("B2:E6").getBorders();
      
       int count = borders.getCount();
       
      Returns:
      The number of border objects in the collection.
    • get

      IBorder get(BordersIndex index)
      Gets a specific IBorder object from the collection by using a BordersIndex value.

      Use this method to access an edge border, inside border, or diagonal border.

      
       IBorders borders = worksheet.getRange("B2:E6").getBorders();
      
       IBorder topBorder = borders.get(BordersIndex.EdgeTop);
       topBorder.setLineStyle(BorderLineStyle.Thick);
       topBorder.setColor(Color.GetRed());
      
       IBorder diagonalDown = borders.get(BordersIndex.DiagonalDown);
       diagonalDown.setLineStyle(BorderLineStyle.Thin);
       
      Parameters:
      index - The BordersIndex value that identifies the border.
      Returns:
      The IBorder object identified by the specified index.
    • clear

      void clear()
      Clears the formatting from the borders in the collection.

      This method clears the collection-level outer and inside border formatting. It does not clear diagonal borders. To clear diagonal borders, access them through get(BordersIndex) with BordersIndex.DiagonalDown or BordersIndex.DiagonalUp.

      
       IBorders borders = worksheet.getRange("B2:E6").getBorders();
       borders.setLineStyle(BorderLineStyle.DashDot);
       borders.setColor(Color.GetRed());
      
       borders.clear();
      
       borders.get(BordersIndex.DiagonalDown).clear();
       borders.get(BordersIndex.DiagonalUp).clear();