[]
        
(Showing Draft Content)

IBorder

Interface IBorder


public interface IBorder
Represents the border of an object.

An IBorder defines the formatting for a single border, including its color, line style, theme color, and tint or shade. Instances are typically obtained from an IBorders collection, such as the borders returned by IRange.getBorders() or IStyle.getBorders().


 IBorder border = worksheet.getRange("A1").getBorders().get(BordersIndex.EdgeBottom);
 border.setLineStyle(BorderLineStyle.Dashed);
 border.setColor(Color.GetBlue());
 
  • Method Details

    • getColor

      Color getColor()
      Gets the Color object assigned directly to this border.

      Use this method to read the border color set by setColor(Color). If the border uses a theme color, use getThemeColor() to read the ThemeColor value instead.

      
       IRange range = worksheet.getRange("B2:D4");
       IBorder border = range.getBorders().get(BordersIndex.EdgeBottom);
       border.setLineStyle(BorderLineStyle.Thick);
       border.setColor(Color.GetRed());
       Color color = border.getColor();
       
      Returns:
      The Color object assigned directly to this border.
    • setColor

      void setColor(Color value)
      Sets the Color object for this border.

      Use this method when you want to apply a fixed color to the border. To apply a color that follows the workbook theme, use setThemeColor(ThemeColor) instead.

      
       IRange range = worksheet.getRange("B2:D4");
       IBorder border = range.getBorders().get(BordersIndex.EdgeBottom);
       border.setLineStyle(BorderLineStyle.Thick);
       border.setColor(Color.GetRed());
       
      Parameters:
      value - The Color object for this border.
    • getColorIndex

      int getColorIndex()
      Gets the color index of this border.

      The returned value can be a palette color index or one of the special values defined by ColorDataIndex, such as ColorDataIndex.Automatic or ColorDataIndex.None. Use ColorDataIndex.forValue(int) to convert a special color index value to the corresponding enum constant.

      
       IBorder border = worksheet.getRange("A1").getBorders().get(BordersIndex.EdgeBottom);
       border.setLineStyle(BorderLineStyle.Thin);
       border.setColorIndex(ColorDataIndex.Automatic.getValue());
       ColorDataIndex colorIndex = ColorDataIndex.forValue(border.getColorIndex());
       
      Returns:
      The color index of this border.
    • setColorIndex

      void setColorIndex(int value)
      Sets the color index of this border.

      The value can be a palette color index or a special value defined by ColorDataIndex. Use 0 to apply the automatic color index.

      
       IBorder border = worksheet.getRange("A1").getBorders().get(BordersIndex.EdgeBottom);
       border.setLineStyle(BorderLineStyle.Thin);
       border.setColorIndex(0);
       
      Parameters:
      value - The color index of this border.
    • getThemeColor

      ThemeColor getThemeColor()
      Gets the ThemeColor value associated with this border.

      Use this method to read the theme-based color assigned to the border. If the border does not use a theme color, this method returns ThemeColor.None.

      
       IBorder border = worksheet.getRange("A1").getBorders().get(BordersIndex.EdgeBottom);
       border.setThemeColor(ThemeColor.Accent1);
       ThemeColor themeColor = border.getThemeColor();
       
      Returns:
      The ThemeColor value associated with this border.
    • setThemeColor

      void setThemeColor(ThemeColor value)
      Sets the ThemeColor value for this border.

      Use this method to apply a workbook theme color to the border instead of a fixed Color. When the workbook theme changes, the displayed border color may change accordingly.

      
       IBorder border = worksheet.getRange("A1").getBorders().get(BordersIndex.EdgeBottom);
       border.setLineStyle(BorderLineStyle.Thin);
      
       // Apply a theme color to the border.
       border.setThemeColor(ThemeColor.Accent1);
       
      Parameters:
      value - The ThemeColor value for this border.
    • getTintAndShade

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

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

      
       IBorder border = worksheet.getRange("A1").getBorders().get(BordersIndex.EdgeBottom);
       border.setColor(Color.GetBlue());
       border.setTintAndShade(0.5);
       double tintAndShade = border.getTintAndShade();
       
      Returns:
      The tint and shade value applied to the border color.
    • setTintAndShade

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

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

      
       IBorder border = worksheet.getRange("A1").getBorders().get(BordersIndex.EdgeBottom);
       border.setColor(Color.GetBlue());
       border.setTintAndShade(0.5);
       
      Parameters:
      value - The tint and shade value applied to the border color.
    • getLineStyle

      BorderLineStyle getLineStyle()
      Gets the line style for the border.
      
       IBorder border = worksheet.getRange("B2:D4").getBorders().get(BordersIndex.EdgeBottom);
       border.setLineStyle(BorderLineStyle.Thick);
       BorderLineStyle lineStyle = border.getLineStyle();
       
      Returns:
      The BorderLineStyle value applied to the border.
    • setLineStyle

      void setLineStyle(BorderLineStyle value)
      Sets the line style for the border.

      Use this method to control how the current border edge is drawn.

      
       IRange range = worksheet.getRange("B2:D4");
       IBorder border = range.getBorders().get(BordersIndex.EdgeBottom);
       border.setLineStyle(BorderLineStyle.Double);
       
      Parameters:
      value - The line style to apply to the border.
    • clear

      void clear()
      Clears the formatting of this border.

      Use this method to remove the current settings applied to a single IBorder, such as its line style and color.

      
       IBorder border = worksheet.getRange("A1").getBorders().get(BordersIndex.EdgeBottom);
       border.setLineStyle(BorderLineStyle.Dashed);
       border.setColor(Color.GetBlue());
       border.clear();