Example:
# Instantiating a Workbook object
workbook = Workbook()
# Obtaining the reference of the first worksheet
worksheet = workbook.getWorksheets().get(0)
# Add new Style to Workbook
style = workbook.createStyle()
# Setting the background color to Blue
style.setBackgroundColor(Color.getBlue())
# Setting the foreground color to Red
style.setForegroundColor(Color.getRed())
# setting Background Pattern
style.setPattern(BackgroundType.DIAGONAL_STRIPE)
# New Style Flag
styleFlag = StyleFlag()
# Set All Styles
styleFlag.setAll(True)
# Get first Column
column = worksheet.getCells().getColumns().get(0)
# Apply Style to first Column
column.applyStyle(style, styleFlag)
# Saving the Excel file
workbook.save("Book1.xls")
| Property Getters/Setters Summary | ||
|---|---|---|
method | getGroupLevel() | |
Gets the group level of the column.
|
||
method | getIndex() | |
Gets the index of this column.
|
||
method | isCollapsed() | |
method | setCollapsed(value) | |
| whether the column is collapsed | ||
method | isHidden() | |
method | setHidden(value) | |
| Indicates whether the column is hidden. | ||
method | getStyle() | |
Gets the style of this column.
|
||
method | getWidth() | |
method | setWidth(value) | |
| Gets and sets the column width in unit of characters. | ||
| Method Summary | ||
|---|---|---|
method | applyStyle(style, flag) | |
Applies formats for a whole column.
|
||
int getIndex()
float getWidth() / setWidth(value)
byte getGroupLevel()
boolean isHidden() / setHidden(value)
Style getStyle()
boolean isCollapsed() / setCollapsed(value)