Example:
# Instantiating a Workbook object workbook = Workbook() # Obtaining the reference of the newly added worksheet by passing its sheet index worksheet = workbook.getWorksheets().get(0) # Accessing the "A1" cell from the worksheet cell = worksheet.getCells().get("A1") # Adding some value to the "A1" cell cell.putValue("Visit Aspose!") # Get style object from cell 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()) # Set style object to cell cell.setStyle(style) # Saving the Excel file workbook.save("Book1.xls")
Property Getters/Setters Summary | ||
---|---|---|
method | getDiagonalColor() | |
method | setDiagonalColor(value) | |
Gets or sets the |
||
method | getDiagonalStyle() | |
method | setDiagonalStyle(value) | |
Gets or sets the style of Diagonal lines. The value of the property is CellBorderType integer constant. | ||
method | getByBorderType(borderType) | |
Gets the |
Method Summary | ||
---|---|---|
method | setColor(color) | |
Sets the |
||
method | setStyle(style) | |
Sets the style of all borders of the collection.
|
Color getDiagonalColor() / setDiagonalColor(value)
int getDiagonalStyle() / setDiagonalStyle(value)
Border getByBorderType(borderType)
borderType
- A setColor(color)
color: Color
- Borders' setStyle(style)
style: int
- A