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.setForegroundColor(Color.getBlue())
# setting Background Pattern
style.setPattern(BackgroundType.SOLID)
# New Style Flag
styleFlag = StyleFlag()
# Set All Styles
styleFlag.setAll(True)
# Change the default width of first ten columns
for i in range(0, 10):
worksheet.getCells().getColumns().get(i).setWidth(20)
# Get the Column with non default formatting
columns = worksheet.getCells().getColumns()
o = columns.iterator()
while o.hasNext():
column = o.next()
# Apply Style to first ten Columns
column.applyStyle(style, styleFlag)
# Saving the Excel file
workbook.save("Book1.xls")
| Property Getters/Setters Summary | ||
|---|---|---|
method | getCount() | |
method | get(columnIndex) | |
Gets a |
||
| Method Summary | ||
|---|---|---|
method | add(value) | |
Reserved for internal use. |
||
method | clear() | |
method | contains(value) | |
Reserved for internal use. |
||
method | get(index) | |
Reserved for internal use. |
||
method | getByIndex(index) | |
Gets the column object by the index.
|
||
method | getColumnByIndex(index) | |
Gets the |
||
method | indexOf(value) | |
Reserved for internal use. |
||
method | iterator() | |
method | removeAt(index) | |
int getCount()
Column get(columnIndex)
Column getByIndex(index)
index: int - Column getColumnByIndex(index)
index: int - The position in the list.clear()
removeAt(index)
Iterator iterator()
Object get(index)
boolean contains(value)
int add(value)
int indexOf(value)