aspose.cells

Class BorderCollection

Encapsulates a collection of Border objects.

Example:

//Instantiating a Workbook object
var workbook = new aspose.cells.Workbook();
//Obtaining the reference of the newly added worksheet by passing its sheet index
var worksheet = workbook.getWorksheets().get(0);
//Accessing the "A1" cell from the worksheet
var cell = worksheet.getCells().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.getBorders().getByBorderType(aspose.cells.BorderType.TOP_BORDER).setLineStyle(aspose.cells.CellBorderType.THICK);
//Setting the color of the top border
style.getBorders().getByBorderType(aspose.cells.BorderType.TOP_BORDER).setColor(aspose.cells.Color.getBlack());
//Setting the line style of the bottom border
style.getBorders().getByBorderType(aspose.cells.BorderType.BOTTOM_BORDER).setLineStyle(aspose.cells.CellBorderType.THICK);
//Setting the color of the bottom border
style.getBorders().getByBorderType(aspose.cells.BorderType.BOTTOM_BORDER).setColor(aspose.cells.Color.getBlack());
//Setting the line style of the left border
style.getBorders().getByBorderType(aspose.cells.BorderType.LEFT_BORDER).setLineStyle(aspose.cells.CellBorderType.THICK);
//Setting the color of the left border
style.getBorders().getByBorderType(aspose.cells.BorderType.LEFT_BORDER).setColor(aspose.cells.Color.getBlack());
//Setting the line style of the right border
style.getBorders().getByBorderType(aspose.cells.BorderType.RIGHT_BORDER).setLineStyle(aspose.cells.CellBorderType.THICK);
//Setting the color of the right border
style.getBorders().getByBorderType(aspose.cells.BorderType.RIGHT_BORDER).setColor(aspose.cells.Color.getBlack());
//Set style object to cell
cell.setStyle(style);

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

Property Getters/Setters Summary
functiongetDiagonalColor()
function
           Gets or sets the com.aspose.cells.Color of Diagonal lines.
functiongetDiagonalStyle()
function
           Gets or sets the style of Diagonal lines. The value of the property is CellBorderType integer constant.
functiongetByBorderType(borderType)
Gets the Border element at the specified index.
 
Method Summary
functionsetColor(color)
Sets the com.aspose.cells.Color of all borders in the collection.
functionsetStyle(style)
Sets the style of all borders of the collection.
 

    • Property Getters/Setters Detail

      • getDiagonalColor/setDiagonalColor : Color 

        function getDiagonalColor() / function setDiagonalColor(value)
        
        Gets or sets the com.aspose.cells.Color of Diagonal lines.
      • getDiagonalStyle/setDiagonalStyle : Number 

        function getDiagonalStyle() / function setDiagonalStyle(value)
        
        Gets or sets the style of Diagonal lines. The value of the property is CellBorderType integer constant.
      • getByBorderType : Border 

        function getByBorderType(borderType)
        
        Gets the Border element at the specified index.
        Parameters:
        borderType - A BorderType value. The border to be retrieved.
        Returns:
        The element at the specified index.
    • Method Detail

      • setColor

        function setColor(color)
        Sets the com.aspose.cells.Color of all borders in the collection.
        Parameters:
        color: Color - Borders' com.aspose.cells.Color.
      • setStyle

        function setStyle(style)
        Sets the style of all borders of the collection.
        Parameters:
        style: Number - A CellBorderType value. Borders' style