[]
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);
voidclear()get(BordersIndex index) IBorder object from the collection by using a BordersIndex value.getColor()Color object applied to the border collection.intintgetCount()ThemeColor value applied to the border collection.doublevoidColor object applied to the border collection.voidsetColorIndex(int value) voidsetLineStyle(BorderLineStyle value) voidsetThemeColor(ThemeColor value) ThemeColor value applied to the border collection.voidsetTintAndShade(double value) 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();
Color object applied to the border collection.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());
value - The Color object to apply 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());
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());
value - The color index to apply to the border collection.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();
ThemeColor value applied to the border collection, or ThemeColor.None if the borders do not use a theme color.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);
value - The ThemeColor value to apply to the border collection.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();
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);
value - The tint and shade value to apply, from -1 (darkest) to 1 (lightest); 0 is neutral.
IBorders borders = worksheet.getRange("B2:E6").getBorders();
borders.setLineStyle(BorderLineStyle.DashDot);
BorderLineStyle lineStyle = borders.getLineStyle();
BorderLineStyle value 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);
value - The border line style to apply to the border 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();
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);
index - The BordersIndex value that identifies the border.IBorder object identified by the specified index.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();