com.aspose.cells

Class BorderCollection

  • java.lang.Object
    • com.aspose.cells.BorderCollection
public class BorderCollection 
extends java.lang.Object

Encapsulates a collection of Border objects.

Example:

//Instantiating a Workbook object
Workbook workbook = new Workbook();

//Adding a new worksheet to the Excel object
workbook.getWorksheets().add();

//Obtaining the reference of the newly added worksheet by passing its sheet index
Worksheet worksheet = workbook.getWorksheets().get(0);

//Accessing the "A1" cell from the worksheet
Cell cell = worksheet.getCells().get("A1");

//Adding some value to the "A1" cell
cell.putValue("Visit Aspose!");

Style style = cell.getStyle();
//Setting the line style of the top border
style.getBorders().getByBorderType(BorderType.TOP_BORDER).setLineStyle(CellBorderType.THICK);

//Setting the color of the top border
style.getBorders().getByBorderType(BorderType.TOP_BORDER).setColor(Color.getBlack());

//Setting the line style of the bottom border
style.getBorders().getByBorderType(BorderType.BOTTOM_BORDER).setLineStyle(CellBorderType.THICK);

//Setting the color of the bottom border
style.getBorders().getByBorderType(BorderType.BOTTOM_BORDER).setColor(Color.getBlack());

//Setting the line style of the left border
style.getBorders().getByBorderType(BorderType.LEFT_BORDER).setLineStyle(CellBorderType.THICK);

//Setting the color of the left border
style.getBorders().getByBorderType(BorderType.LEFT_BORDER).setColor(Color.getBlack());

//Setting the line style of the right border
style.getBorders().getByBorderType(BorderType.RIGHT_BORDER).setLineStyle(CellBorderType.THICK);

//Setting the color of the right border
style.getBorders().getByBorderType(BorderType.RIGHT_BORDER).setColor(Color.getBlack());

cell.setStyle(style);

//Saving the Excel file
workbook.save("C:\\book1.xls");

Property Getters/Setters Summary
com.aspose.cells.ColorgetDiagonalColor()
void
setDiagonalColor(com.aspose.cells.Colorvalue)
           Gets or sets the com.aspose.cells.Color of Diagonal lines.
intgetDiagonalStyle()
void
           Gets or sets the style of Diagonal lines. The value of the property is CellBorderType integer constant.
BordergetByBorderType(int borderType)
Gets the Border element at the specified index.
 
Method Summary
voidsetColor(com.aspose.cells.Color color)
Sets the com.aspose.cells.Color of all borders in the collection.
voidsetStyle(int style)
Sets the style of all borders of the collection.
 

    • Property Getters/Setters Detail

      • getDiagonalColor/setDiagonalColor

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

        public int getDiagonalStyle() / public void setDiagonalStyle(int value)
        
        Gets or sets the style of Diagonal lines. The value of the property is CellBorderType integer constant.
      • getByBorderType

        public Border getByBorderType(int 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.

    setDiagonalColor

    public voidsetDiagonalColor(com.aspose.cells.Colorvalue)
    
    Gets or sets the com.aspose.cells.Color of Diagonal lines.

    setDiagonalStyle

    public voidsetDiagonalStyle(intvalue)
    
    Gets or sets the style of Diagonal lines. The value of the property is CellBorderType integer constant.
    • Method Detail

      • setColor

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

        public void setStyle(int style)
        Sets the style of all borders of the collection.
        Parameters:
        style - A CellBorderType value. Borders' style