public class BorderCollection
extends java.lang.Object
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("book1.xls");
| Modifier and Type | Method and Description |
|---|---|
Border |
getByBorderType(int borderType)
Gets the
Border element at the specified index. |
Color |
getDiagonalColor()
Gets the
Color of Diagonal lines. |
int |
getDiagonalStyle()
Gets the style of Diagonal lines.
|
void |
setColor(Color color)
Sets the
Color of all borders in the collection. |
void |
setDiagonalColor(Color value)
Sets the
Color of Diagonal lines. |
void |
setDiagonalStyle(int value)
Sets the style of Diagonal lines.
|
void |
setStyle(int style)
Sets the style of all borders of the collection.
|
public Border getByBorderType(int borderType)
Border element at the specified index.borderType - BorderType. The border to be retrieved.public void setColor(Color color)
Color of all borders in the collection.color - Borders' Color.public void setStyle(int style)
style - CellBorderType. Borders' stylepublic int getDiagonalStyle()
See CellBorderType.
public void setDiagonalStyle(int value)
See CellBorderType.
See Also:
Aspose.Cells Documentation - the home page for the Aspose.Cells Product Documentation.
Aspose.Cells Support Forum - our preferred method of support.
We guarantee a prompt response to any inquiry!
© Aspose Pty Ltd 2003-2025. All Rights Reserved.