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 | 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. |
Property Getters/Setters Detail |
---|
getIndex : int | |
int getIndex() |
getWidth/setWidth : float | |
float getWidth() / setWidth(value) |
getGroupLevel : byte | |
byte getGroupLevel() |
isHidden/setHidden : boolean | |
boolean isHidden() / setHidden(value) |
getStyle : Style | |
Style getStyle() |
Method Detail |
---|
applyStyle | |
applyStyle(style, flag) |
style: Style
- The style object which will be applied.flag: StyleFlag
- Flags which indicates applied formatting properties.