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() | |
method | setGroupLevel(value) | |
Gets the group level of the column. | ||
method | hasCustomStyle() | |
Indicates whether this column has custom style settings(different from the default one inherited from workbook).
|
||
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 | 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.
|
||
method | getStyle() | |
Gets the style of this column.
|
||
method | setStyle(style) | |
Sets the style of this column.
|
int getIndex()
float getWidth() / setWidth(value)
byte getGroupLevel() / setGroupLevel(value)
boolean isHidden() / setHidden(value)
boolean hasCustomStyle()
boolean isCollapsed() / setCollapsed(value)
applyStyle(style, flag)
style: Style
- The style object which will be applied.flag: StyleFlag
- Flags which indicates applied formatting properties.Style getStyle()
setStyle(style)
style: Style
- the style to be used as the default style for cells in this column.