BorderCollection

BorderCollection class

Encapsulates a collection of Border objects.

class BorderCollection;

Example

const { Workbook, BorderType, CellBorderType, Color } = require("aspose.cells.node");

//Instantiating a Workbook object
var workbook = new Workbook();
//Obtaining the reference of the newly added worksheet by passing its sheet index
var worksheet = workbook.worksheets.get(0);
//Accessing the "A1" cell from the worksheet
var cell = worksheet.cells.get("A1");
//Adding some value to the "A1" cell
cell.putValue("Visit Aspose!");
//Get style object from cell
var style = cell.getStyle();
//Setting the line style of the top border
style.borders.get(BorderType.TopBorder).lineStyle = CellBorderType.Thick;
//Setting the color of the top border
style.borders.get(BorderType.TopBorder).color = Color.Black;
//Setting the line style of the bottom border
style.borders.get(BorderType.BottomBorder).lineStyle = CellBorderType.Thick;
//Setting the color of the bottom border
style.borders.get(BorderType.BottomBorder).color = Color.Black;
//Setting the line style of the left border
style.borders.get(BorderType.LeftBorder).lineStyle = CellBorderType.Thick;
//Setting the color of the left border
style.borders.get(BorderType.LeftBorder).color = Color.Black;
//Setting the line style of the right border
style.borders.get(BorderType.RightBorder).lineStyle = CellBorderType.Thick;
//Setting the color of the right border
style.borders.get(BorderType.RightBorder).color = Color.Black;
//Set style object to cell
cell.setStyle(style);

//Saving the Excel file
workbook.save("output/BorderCollection.xls");

Properties

PropertyTypeDescription
isOutlinebooleanIndicates if left, right, top, and bottom borders should be applied only to outside borders of a cell range. Default value is true.
diagonalColorColorGets or sets the Color of Diagonal lines.
diagonalStyleCellBorderTypeGets or sets the style of Diagonal lines.

Methods

MethodDescription
get(BorderType)Gets the Border element at the specified index.
isOutline()@deprecated. Please use the ‘isOutline’ property instead. Indicates if left, right, top, and bottom borders should be applied only to outside borders of a cell range. Default value is true.
setIsOutline(boolean)@deprecated. Please use the ‘isOutline’ property instead. Indicates if left, right, top, and bottom borders should be applied only to outside borders of a cell range. Default value is true.
getDiagonalColor()@deprecated. Please use the ‘diagonalColor’ property instead. Gets or sets the Color of Diagonal lines.
setDiagonalColor(Color)@deprecated. Please use the ‘diagonalColor’ property instead. Gets or sets the Color of Diagonal lines.
getDiagonalStyle()@deprecated. Please use the ‘diagonalStyle’ property instead. Gets or sets the style of Diagonal lines.
setDiagonalStyle(CellBorderType)@deprecated. Please use the ‘diagonalStyle’ property instead. Gets or sets the style of Diagonal lines.
setColor(Color)Sets the Color of all borders in the collection.
setStyle(CellBorderType)Sets the style of all borders of the collection.
isNull()Checks whether the implementation object is null.

isOutline

Indicates if left, right, top, and bottom borders should be applied only to outside borders of a cell range. Default value is true.

isOutline : boolean;

Remarks

Only works when applying to a range for conditional formattings, pivot tables. If false,left, right, top, and bottom will apply to each cell, otherwise only to outside borders of a cell range. If true, please set horizontal and vertical border of inner borders of range for conditional formattings, pivot tables.

diagonalColor

Gets or sets the Color of Diagonal lines.

diagonalColor : Color;

diagonalStyle

Gets or sets the style of Diagonal lines.

diagonalStyle : CellBorderType;

get(BorderType)

Gets the Border element at the specified index.

get(borderType: BorderType) : Border;

Parameters:

ParameterTypeDescription
borderTypeBorderTypeThe border to be retrieved.

Returns

The element at the specified index.

isOutline()

@deprecated. Please use the ‘isOutline’ property instead. Indicates if left, right, top, and bottom borders should be applied only to outside borders of a cell range. Default value is true.

isOutline() : boolean;

Remarks

Only works when applying to a range for conditional formattings, pivot tables. If false,left, right, top, and bottom will apply to each cell, otherwise only to outside borders of a cell range. If true, please set horizontal and vertical border of inner borders of range for conditional formattings, pivot tables.

setIsOutline(boolean)

@deprecated. Please use the ‘isOutline’ property instead. Indicates if left, right, top, and bottom borders should be applied only to outside borders of a cell range. Default value is true.

setIsOutline(value: boolean) : void;

Parameters:

ParameterTypeDescription
valuebooleanThe value to set.

Remarks

Only works when applying to a range for conditional formattings, pivot tables. If false,left, right, top, and bottom will apply to each cell, otherwise only to outside borders of a cell range. If true, please set horizontal and vertical border of inner borders of range for conditional formattings, pivot tables.

getDiagonalColor()

@deprecated. Please use the ‘diagonalColor’ property instead. Gets or sets the Color of Diagonal lines.

getDiagonalColor() : Color;

Returns

Color

setDiagonalColor(Color)

@deprecated. Please use the ‘diagonalColor’ property instead. Gets or sets the Color of Diagonal lines.

setDiagonalColor(value: Color) : void;

Parameters:

ParameterTypeDescription
valueColorThe value to set.

getDiagonalStyle()

@deprecated. Please use the ‘diagonalStyle’ property instead. Gets or sets the style of Diagonal lines.

getDiagonalStyle() : CellBorderType;

Returns

CellBorderType

setDiagonalStyle(CellBorderType)

@deprecated. Please use the ‘diagonalStyle’ property instead. Gets or sets the style of Diagonal lines.

setDiagonalStyle(value: CellBorderType) : void;

Parameters:

ParameterTypeDescription
valueCellBorderTypeThe value to set.

setColor(Color)

Sets the Color of all borders in the collection.

setColor(color: Color) : void;

Parameters:

ParameterTypeDescription
colorColorBorders’ Color.

setStyle(CellBorderType)

Sets the style of all borders of the collection.

setStyle(style: CellBorderType) : void;

Parameters:

ParameterTypeDescription
styleCellBorderTypeBorders’ style

isNull()

Checks whether the implementation object is null.

isNull() : boolean;